ayuda por favor.... soy nueva...

Eyre
13 de Marzo del 2006
Hola
Soy nueva en todo esto y necesito vuestra ayuda.
Mirad, tengo una variable string con contenido xml y quiero leer sus valores.

¿Como puedo hacerlo? ¿Tenéis algún ejemplo?

Muchas gracias,

Eyre

i?
13 de Marzo del 2006
Espero que te sirva mi fragmento de codigo. La verdad s q yo no tengo mucha idea pero ami me funciona. Lo unico que yo no lo tengo en una string sino que lo leo desde un txt.


'DATOS DEL CLIENTE
Dim DNI As String = ""
Dim Nombre As String = ""
Dim Apellidos As String = ""
Dim direccion1 As String = ""
Dim direccion2 As String = ""
Dim direccion3 As String = ""
Dim poblacion As String = ""
Dim provincia As String = ""
Dim Cp As String = ""
Dim pais As String = ""
Dim Telefono As String = ""
'OTROS DATOS DE INTERES COMO EL TELEFONO...
Dim FechaCompra As String = ""
Dim email As String = ""

'DATOS DE ENTREGA
Dim empresa As String = ""
Dim nombrecontacto As String = ""
Dim Apellidoscontacto As String = ""
Dim direccionentrega As String = ""
Dim direccionentrega2 As String = ""
Dim direccionentrega3 As String = ""
Dim poblacionentrega As String = ""
Dim provinciaentrega As String = ""
Dim cpentrega As String = ""
Dim paisentrega As String = ""
Dim Telefonoentrega As String = ""
'DATOS DEL PRODUCTO
Dim id_referencia As String = ""
Dim cantidad As String = ""
Dim precio As String = ""
Dim total As String = ""
Dim totalConGastos As String = ""
'PARA EL XML********************************************************************
Dim myXmlDocument As Xml.XmlDocument = New Xml.XmlDocument()
If Not My.Computer.FileSystem.FileExists(CurDir() & "/Etiendas/orderlist.xml") Then
MsgBox("No existe el archivo a importar en la carpeta " & CurDir() & "/Etiendas/ o el archivo no se llama orderlist.xml")
End If
myXmlDocument.Load(CurDir() & "/Etiendas/orderlist.xml")
Dim node As Xml.XmlNode
node = myXmlDocument.DocumentElement
Dim node2 As Xml.XmlNode
'*******************************************************************************
For Each node In node.ChildNodes
For Each node2 In node.ChildNodes
If node2.Name = "ordertime" Then FechaCompra = node2.InnerText
If node2.Name = "email" Then email = node2.InnerText
If node2.Name = "contacttel" Then Telefono = node2.InnerText
'PARA EL DNI****************************************************************
If node2.Name = "extrainfo" Then
For Each node5 As Xml.XmlNode In node2.ChildNodes
If node5.Name = "field" Then
For Each node6 As Xml.XmlNode In node5.ChildNodes
If node6.Name = "fieldvalue" Then DNI = node6.InnerText
Next
End If
Next
End If
'***************************************************************************
'DATOS DEL CLIENTE**********************************************************
If node2.Name = "billing" Then
For Each node3 As Xml.XmlNode In node2.ChildNodes
If node3.Name = "firstname" Then Nombre = node3.InnerText
If node3.Name = "surname" Then Apellidos = node3.InnerText
If node3.Name = "address1" Then direccion1 = node3.InnerText
If node3.Name = "address2" Then direccion2 = node3.InnerText
If node3.Name = "address3" Then direccion3 = node3.InnerText
If node3.Name = "town" Then poblacion = node3.InnerText
If node3.Name = "county" Then provincia = node3.InnerText
If node3.Name = "postcode" Then Cp = node3.InnerText
If node3.Name = "country" Then pais = node3.InnerText
Next
End If
'****************************************************************************
'DATOS DE ENTREGA************************************************************
If node2.Name = "delivery" Then
For Each node4 As Xml.XmlNode In node2.ChildNodes
If node4.Name = "deltitle" Then empresa = node4.InnerText
If node4.Name = "delfirstname" Then nombrecontacto = node4.InnerText
If node4.Name = "delsurname" Then Apellidoscontacto = node4.InnerText
If node4.Name = "deladdress1" Then direccionentrega = node4.InnerText
If node4.Name = "deladdress2" Then direccionentrega2 = node4.InnerText
If node4.Name = "deladdress3" Then direccionentrega3 = node4.InnerText
If node4.Name = "deltown" Then poblacionentrega = node4.InnerText
If node4.Name = "delcounty" Then provinciaentrega = node4.InnerText
If node4.Name = "delpostcode" Then cpentrega = node4.InnerText
If node4.Name = "delcountry" Then paisentrega = node4.InnerText
If node4.Name = "deltelephone" Then Telefonoentrega = node4.InnerText
Next
End If
'****************************************************************************
'DATOS DEL PRODUCTO**********************************************************
If node2.Name = "orderitems" Then
For Each node7 As Xml.XmlNode In node2.ChildNodes
If node7.Name = "item" Then
For Each node8 As Xml.XmlNode In node7.ChildNodes
If node8.Name = "sku" Then id_referencia = node8.InnerText
If node8.Name = "quantity" Then cantidad = node8.InnerText
If node8.Name = "linecost" Then precio = node8.InnerText
Next
End If
Next
End If
If node2.Name = "orderMerchants" Then
For Each node7 As Xml.XmlNode In node2.ChildNodes
If node7.Name = "merchant" Then
For Each node8 As Xml.XmlNode In node7.ChildNodes
If node8.Name = "total" Then total = node8.InnerText
If node8.Name = "merchanttotal" Then totalConGastos = node8.InnerText
Next
End If
Next
End If
Next
Next

i?
13 de Marzo del 2006
Te paso mi fragmento de codigo que ami me funciona.
Yo tampoco tengo demasiada idea pero bueno.
Solo que no esta en variable string sino uqe lo leo de un fichero .txt.
'DATOS DEL CLIENTE
Dim DNI As String = ""
Dim Nombre As String = ""
Dim Apellidos As String = ""
Dim direccion1 As String = ""
Dim direccion2 As String = ""
Dim direccion3 As String = ""
Dim poblacion As String = ""
Dim provincia As String = ""
Dim Cp As String = ""
Dim pais As String = ""
Dim Telefono As String = ""
'OTROS DATOS DE INTERES COMO EL TELEFONO...
Dim FechaCompra As String = ""
Dim email As String = ""

'DATOS DE ENTREGA
Dim empresa As String = ""
Dim nombrecontacto As String = ""
Dim Apellidoscontacto As String = ""
Dim direccionentrega As String = ""
Dim direccionentrega2 As String = ""
Dim direccionentrega3 As String = ""
Dim poblacionentrega As String = ""
Dim provinciaentrega As String = ""
Dim cpentrega As String = ""
Dim paisentrega As String = ""
Dim Telefonoentrega As String = ""
'DATOS DEL PRODUCTO
Dim id_referencia As String = ""
Dim cantidad As String = ""
Dim precio As String = ""
Dim total As String = ""
Dim totalConGastos As String = ""
'PARA EL XML********************************************************************
Dim myXmlDocument As Xml.XmlDocument = New Xml.XmlDocument()
If Not My.Computer.FileSystem.FileExists(CurDir() & "/Etiendas/orderlist.xml") Then
MsgBox("No existe el archivo a importar en la carpeta " & CurDir() & "/Etiendas/ o el archivo no se llama orderlist.xml")
End If
myXmlDocument.Load(CurDir() & "/Etiendas/orderlist.xml")
Dim node As Xml.XmlNode
node = myXmlDocument.DocumentElement
Dim node2 As Xml.XmlNode
'*******************************************************************************
For Each node In node.ChildNodes
For Each node2 In node.ChildNodes
If node2.Name = "ordertime" Then FechaCompra = node2.InnerText
If node2.Name = "email" Then email = node2.InnerText
If node2.Name = "contacttel" Then Telefono = node2.InnerText
'PARA EL DNI****************************************************************
If node2.Name = "extrainfo" Then
For Each node5 As Xml.XmlNode In node2.ChildNodes
If node5.Name = "field" Then
For Each node6 As Xml.XmlNode In node5.ChildNodes
If node6.Name = "fieldvalue" Then DNI = node6.InnerText
Next
End If
Next
End If
'***************************************************************************
'DATOS DEL CLIENTE**********************************************************
If node2.Name = "billing" Then
For Each node3 As Xml.XmlNode In node2.ChildNodes
If node3.Name = "firstname" Then Nombre = node3.InnerText
If node3.Name = "surname" Then Apellidos = node3.InnerText
If node3.Name = "address1" Then direccion1 = node3.InnerText
If node3.Name = "address2" Then direccion2 = node3.InnerText
If node3.Name = "address3" Then direccion3 = node3.InnerText
If node3.Name = "town" Then poblacion = node3.InnerText
If node3.Name = "county" Then provincia = node3.InnerText
If node3.Name = "postcode" Then Cp = node3.InnerText
If node3.Name = "country" Then pais = node3.InnerText
Next
End If
'****************************************************************************
'DATOS DE ENTREGA************************************************************
If node2.Name = "delivery" Then
For Each node4 As Xml.XmlNode In node2.ChildNodes
If node4.Name = "deltitle" Then empresa = node4.InnerText
If node4.Name = "delfirstname" Then nombrecontacto = node4.InnerText
If node4.Name = "delsurname" Then Apellidoscontacto = node4.InnerText
If node4.Name = "deladdress1" Then direccionentrega = node4.InnerText
If node4.Name = "deladdress2" Then direccionentrega2 = node4.InnerText
If node4.Name = "deladdress3" Then direccionentrega3 = node4.InnerText
If node4.Name = "deltown" Then poblacionentrega = node4.InnerText
If node4.Name = "delcounty" Then provinciaentrega = node4.InnerText
If node4.Name = "delpostcode" Then cpentrega = node4.InnerText
If node4.Name = "delcountry" Then paisentrega = node4.InnerText
If node4.Name = "deltelephone" Then Telefonoentrega = node4.InnerText
Next
End If
'****************************************************************************
'DATOS DEL PRODUCTO**********************************************************
If node2.Name = "orderitems" Then
For Each node7 As Xml.XmlNode In node2.ChildNodes
If node7.Name = "item" Then
For Each node8 As Xml.XmlNode In node7.ChildNodes
If node8.Name = "sku" Then id_referencia = node8.InnerText
If node8.Name = "quantity" Then cantidad = node8.InnerText
If node8.Name = "linecost" Then precio = node8.InnerText
Next
End If
Next
End If
If node2.Name = "orderMerchants" Then
For Each node7 As Xml.XmlNode In node2.ChildNodes
If node7.Name = "merchant" Then
For Each node8 As Xml.XmlNode In node7.ChildNodes
If node8.Name = "total" Then total = node8.InnerText
If node8.Name = "merchanttotal" Then totalConGastos = node8.InnerText
Next
End If
Next
End If
Next
Next