begin process at 2008 07 07 02:35:29
1 205 881 membres
32 nouveaux aujourd'hui
14 120 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

Sujet : fichier xml: lire les attributs [ Archives Visual Basic / J'AI BESOIN D'AIDE !!!! :) ] (chris21)

fichier xml: lire les attributs le 19/09/2003 09:00:56

chris21
bonjour à tous j'ai un fichier xml de ce type:[blue]<rutas>
<ruta tipo="central" url="/imagenes/home/home/directorio_gg/sansebastian03_gg.swf"
enlace="/edicion/cm/bin/"/>
<ruta tipo="central" url="/imagenes/home/home/directorio_mm/abajoelamor_mm.swf"
enlace="/edicion/cm/bin/"/>
<ruta tipo="central" url="/imagenes/home/home/directorio_mm/seanconnery_mm.swf"
enlace="/edicion/cm/bin/"/>
<ruta tipo="central" url="/imagenes/home/home/directorio_mm/soldadosdesalamina_mm.swf"
enlace="/edicion/cm/bin/"/>
<ruta tipo="central" url="/imagenes/home/home/directorio_mm/lascarasderipley_mm.swf"
enlace="/edicion/cm/bin"/>
<ruta tipo="promocion" url="/imagenes/home/home/directorio_g/cartelera_g.swf"/>
</rutas>
[blue]
En fait j'aimerais pouvoir lire les attributs de mes nodes et je n'y arrive pas.. Qu'elle est la syntaxe??
Merci

Re : fichier xml: lire les attributs le 19/09/2003 09:26:01

Renfield
(Admin CS)
as tu ajouté une reference a 'Microsoft XML' ?

ca te donnes acces a tout un tas de fonctions qui viendraient a bout de ton probleme.

By Renfield

mailto:thomas_reynald@msn.com

Aucune touche n'a été blessée lors de la saisie de ce texte..........


-------------------------------
Réponse au message :
-------------------------------

> bonjour à tous j'ai un fichier xml de ce type:[blue]<rutas>
> <ruta tipo="central" url="/imagenes/home/home/directorio_gg/sansebastian03_gg.swf"
> enlace="/edicion/cm/bin/"/>
> <ruta tipo="central" url="/imagenes/home/home/directorio_mm/abajoelamor_mm.swf"
> enlace="/edicion/cm/bin/"/>
> <ruta tipo="central" url="/imagenes/home/home/directorio_mm/seanconnery_mm.swf"
> enlace="/edicion/cm/bin/"/>
> <ruta tipo="central" url="/imagenes/home/home/directorio_mm/soldadosdesalamina_mm.swf"
> enlace="/edicion/cm/bin/"/>
> <ruta tipo="central" url="/imagenes/home/home/directorio_mm/lascarasderipley_mm.swf"
> enlace="/edicion/cm/bin"/>
> <ruta tipo="promocion" url="/imagenes/home/home/directorio_g/cartelera_g.swf"/>
> </rutas>
> [blue]
> En fait j'aimerais pouvoir lire les attributs de mes nodes et je n'y arrive pas.. Qu'elle est la syntaxe??
> Merci

Re : fichier xml: lire les attributs le 19/09/2003 09:31:32

chris21


oui bien sûr, j'arrive à lire le xml, mais pas à séparer les éléments. j'arrive à compter le nombre de nodes, etc... mais je trouve l'aide pas très claire.

-------------------------------
Réponse au message :
-------------------------------

> as tu ajouté une reference a 'Microsoft XML' ?
>
> ca te donnes acces a tout un tas de fonctions qui viendraient a bout de ton probleme.
>
> By Renfield
>
> mailto:thomas_reynald@msn.com
>
> Aucune touche n'a été blessée lors de la saisie de ce texte..........
>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > bonjour à tous j'ai un fichier xml de ce type:[blue]<rutas>
> > <ruta tipo="central" url="/imagenes/home/home/directorio_gg/sansebastian03_gg.swf"
> > enlace="/edicion/cm/bin/"/>
> > <ruta tipo="central" url="/imagenes/home/home/directorio_mm/abajoelamor_mm.swf"
> > enlace="/edicion/cm/bin/"/>
> > <ruta tipo="central" url="/imagenes/home/home/directorio_mm/seanconnery_mm.swf"
> > enlace="/edicion/cm/bin/"/>
> > <ruta tipo="central" url="/imagenes/home/home/directorio_mm/soldadosdesalamina_mm.swf"
> > enlace="/edicion/cm/bin/"/>
> > <ruta tipo="central" url="/imagenes/home/home/directorio_mm/lascarasderipley_mm.swf"
> > enlace="/edicion/cm/bin"/>
> > <ruta tipo="promocion" url="/imagenes/home/home/directorio_g/cartelera_g.swf"/>
> > </rutas>
> > [blue]
> > En fait j'aimerais pouvoir lire les attributs de mes nodes et je n'y arrive pas.. Qu'elle est la syntaxe??
> > Merci
>

Re : fichier xml: lire les attributs le 19/09/2003 10:11:22

Renfield
(Admin CS)
J'ai mis ton fichier dans un fichier.xml, et j'ai fais ca :


Private Sub Form_Load()
Dim XML As New DOMDocument30
XML.Load App.Path & "\Fil.xml"

Dim Rutas As IXMLDOMNode
Set Rutas = XML.firstChild

Dim Node As IXMLDOMNode

For Each Node In Rutas.childNodes
Debug.Print "Ruta", "tipo = " & NodeAttribute(Node, "tipo"), "url = " & NodeAttribute(Node, "url"), "enlace = " & NodeAttribute(Node, "enlace")
Next Node
End
End Sub

Function NodeAttribute(lNode As IXMLDOMNode, AttributeName As String) As String
Dim NodeAtt As IXMLDOMAttribute
For Each NodeAtt In lNode.Attributes
If NodeAtt.Name = AttributeName Then
NodeAttribute = NodeAtt.Text
Exit Function
End If
Next NodeAtt
Set NodeAtt = Nothing
End Function


By Renfield

mailto:thomas_reynald@msn.com

Aucune touche n'a été blessée lors de la saisie de ce texte..........

Re : fichier xml: lire les attributs le 19/09/2003 10:28:06

chris21
ça ne marche pas chez moi, t'as mis quoi comme référence? j'ai ajouté microsoft ado et microsoft xml 2.0.
merci pour ton aide



-------------------------------
Réponse au message :
-------------------------------

> J'ai mis ton fichier dans un fichier.xml, et j'ai fais ca :
>
>

> Private Sub Form_Load()
> Dim XML As New DOMDocument30
> XML.Load App.Path & "\Fil.xml"
>
> Dim Rutas As IXMLDOMNode
> Set Rutas = XML.firstChild
>
> Dim Node As IXMLDOMNode
>
> For Each Node In Rutas.childNodes
> Debug.Print "Ruta", "tipo = " & NodeAttribute(Node, "tipo"), "url = " & NodeAttribute(Node, "url"), "enlace = " & NodeAttribute(Node, "enlace")
> Next Node
> End
> End Sub
>
> Function NodeAttribute(lNode As IXMLDOMNode, AttributeName As String) As String
> Dim NodeAtt As IXMLDOMAttribute
> For Each NodeAtt In lNode.Attributes
> If NodeAtt.Name = AttributeName Then
> NodeAttribute = NodeAtt.Text
> Exit Function
> End If
> Next NodeAtt
> Set NodeAtt = Nothing
> End Function
>

>
> By Renfield
>
> mailto:thomas_reynald@msn.com
>
> Aucune touche n'a été blessée lors de la saisie de ce texte..........
>

Re : fichier xml: lire les attributs le 19/09/2003 11:22:27

chris21
j'ai trouvé, par exemple pour afficher les url dans un msgbox, voici mon code:
Function chargement(fichero)
Dim numerorutas As Integer
Dim i As Integer
Dim objxml As New MSXML.DOMDocument
Dim xmllist As MSXML.IXMLDOMNodeList
Dim xmlnode As MSXML.IXMLDOMNode
Dim argumentos As MSXML.IXMLDOMAttribute
objxml.validateOnParse = False
objxml.async = False
If objxml.Load(Dir1.Path & "\" & fichero) Then
'MsgBox ("objxml.Text " & objxml.Text)
Set xmllist = objxml.selectNodes("//rutas/ruta")
'MsgBox argumentos
numerorutas = xmllist.length
MsgBox ("xmllist.lenght " & numerorutas)
For Each xmlnode In xmllist
Set argumentos = xmlnode.Attributes(1)
MsgBox argumentos.Text
'MsgBox ("xmlnode.Text " & xmlnode.Text)
i = i + 1
Next
MsgBox ("numero de attributos " & i)
On Error GoTo ErrorHandler
objxml.validateOnParse = True
Else
MsgBox "res"
End If
Set objxml = Nothing
Exit Function
ErrorHandler:
MsgBox Err.Description
Set objxml = Nothing
End Function




Classé sous : fichier, lire, xml, blue, attributs

Participer à cet échange

Pub



Appels d'offres

Realisation graphique ...
Budget : 700€
WEB DESIGN
Budget : 1 000€
Plugin Dialer outlook
Budget : 2 000€

CalendriCode

Juillet 2008
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Téléchargements

Logiciels à télécharger sur le même thème :

Boutique

Boutique de goodies CodeS-SourceS