Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Langages serveur > ASP
ASP Forum sur la programmation ASP. Avant de poster : Cours ASP, FAQ ASP
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 28/05/2007, 23h23   #1
Nouveau Membre du Club
 
Inscription : juin 2006
Messages : 218
Détails du profil
Informations forums :
Inscription : juin 2006
Messages : 218
Points : 39
Points : 39
Par défaut Générer un document XML

Salut de nouveau!

Je n'arrive plus à résoudre mon problème.... C'est la première fois que
j'utilise cette technique pour générer un document XML qui a la forme
suivante:

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
 <?xml version="1.0"?>
 <gallery>
            <galleryname>Nature</galleryname>
            <images>
                    <image>
                         <filename>dataaa</filename>
                          <description>dataaa</description>
                          <date>03-02-07</date>
                   </image>
                   <image>
                                           .....
                  </image>
            </images>
            </galleryname>
 </gallery>
Erreur : xml document must have a top level element


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
<%@LANGUAGE="VBSCRIPT"%>
<%
 
 Response.ContentType="text/XML"
 
  Dim objDom 
  Dim objRoot
  .....
 
  filePath = Server.MapPath("BDPhotographers.mdb")
  Set Connection=Server.CreateObject("ADODB.Connection")
  Connection.Open="Provider=Microsoft.jet.OLEDB.4.0;Data source="&filepath
 
  sql="SELECT * From Photos"
 
  set obj_Recordset=Server.CreateObject("ADODB.Recordset")
  obj_Recordset.open sql, Connection
 
 
  IF not obj_Recordset.EOF then
 
  Set objDom = Server.CreateObject("Microsoft.XMLDOM")
  objDom.preserveWhiteSpace =  True
 
  Set objRoot = objDom.createElement("gallery")
  objDom.appendChild objRoot
 
  obj_Recordset.MoveFirst
  DO WHILE NOT obj_Recordset.EOF
 
  Set objChild1 = objDom.createElement("galleryName")
  objChild1.Text=Request.Form("gal1")
  objRoot.appendChild objChild1
 
  Set objChild2 = objDom.createElement("images")
  objRoot.appendChild objChild2
 
  Set objChild3 = objDom.createElement("image")
  objChild2.appendChild objChild3
 
  Set objChild4 = objDom.createElement("filename")
  objChild4.Text=Request.Form("file1")
  objChild3.appendChild objChild4
 
  Set objChild5 = objDom.createElement("description")
  objChild5.Text=Request.Form("desc1")
  objChild3.appendChild objChild5
 
  Set objChild6 = objDom.createElement("date")
  objChild6.Text=Request.Form("date1")
  objChild3.appendChild objChild6
 
  obj_Recordset.MoveNext
  LOOP
 
 END IF
 
 Set objPI = objDom.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8' ")
 objDom.insertBefore objPI, objDom.childNodes(0) 
 
 objDom.Save "C:\Inetpub\wwwroot\WebProject\photoGal.xml"
%>
Identifiant est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/05/2007, 11h51   #2
Modérateur
 
Avatar de roro06
 
Inscription : avril 2007
Messages : 1 364
Détails du profil
Informations personnelles :
Âge : 42

Informations forums :
Inscription : avril 2007
Messages : 1 364
Points : 1 551
Points : 1 551
Bonjour

Dans ton xml, tu as une balise de trop :
</galleryname>
roro06 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/05/2007, 12h28   #3
Nouveau Membre du Club
 
Inscription : juin 2006
Messages : 218
Détails du profil
Informations forums :
Inscription : juin 2006
Messages : 218
Points : 39
Points : 39
c'est vrai .. I did it by inadvertance. Le code XML est ce que je désire avoir en sortie, càd après l'exécution du code ASP.
Identifiant est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/05/2007, 14h23   #4
Nouveau Membre du Club
 
Inscription : juin 2006
Messages : 218
Détails du profil
Informations forums :
Inscription : juin 2006
Messages : 218
Points : 39
Points : 39
et finalement j'ai abouti à résoudre mon prob.
Identifiant est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 19h50.


 
 
 
 
Partenaires

Hébergement Web