Click here to Skip to main content
15,888,157 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello community

I have the following query. I'm working with a PROYECO made ​​in visual basic, using visual studio 2008.

The project is to run a web service, which I receive in response a string in XML format

Within the data cycles to bring in a bill the following line.

XML
<FechaXML xmlns = "xxxx: //xxx.xxxxxxxxx.xx/xxxxxx"> 2014-10-30T17: 01: 49 </ FechaXML> <document ID = "6078729" xmlns="xxxx://xxx.xxxxxxxxx.xxx/xxxxxx"><LineasFactSinOc></LineasFactSinOc><Encabezado><IdDoc><TipoDoc>FC</TipoDoc><NumDoc>3257</NumDoc><FolioUnico>0101-368247</FolioUnico><FchTransaccion>2014-05-30T19:23:08</FchTransaccion><FchEmis>2014-01-09</FchEmis><FchVenc>2014-04-12</FchVenc><FchRecepcion>2014-01-21</FchRecepcion><FchEstimadaPago>2014-02-21</FchEstimadaPago><Comentarios>Nombre User: SARANCIBIAA Number ...

It is a part of xml text, to explain the fact that I want to extract

I use the follwing code to Get That part
VB
documentoXML.LoadXml(testxml.InnerXml)
           NodeLista = documentoXML.FirstChild.FirstChild.FirstChild.ChildNodes
           For Each Nodo In NodeLista
               Cuenta = Cuenta + 1
               CuentaNodo = CuentaNodo + 1
               Dim Resultado As String

                     If Nodo.LocalName = "ICDoc" Then
                      Resultado = Nodo.InnerXml.Substring(83, 23)
                      MsgBox(Resultado


The xml text is assigned to the variable "Resultado".

How do I can get the Document ID part = "6078729" only the value that is in quotes? that this value changes increase or decrease the number of digits, can be "12", "10000" ... is there any way to count the digits from the first to the second quote?

if information needed to understand the problem please notify or consult thanks
Posted
Updated 3-Nov-14 11:45am
v2

VB
dim xl as string = "<Categories>" + "<category name=""a"">" + "<SubCategory>1</SubCategory>" + "<SubCategoryName>name1</SubCategoryName>" + "</category>" + "<category name=""b"">" + "<SubCategory>2</SubCategory>" + "<SubCategoryName>name2</SubCategoryName>" + "</category>" + "</Categories>"
dim xdoc as new XmlDocument()
xdoc.LoadXml(xl)
For Each node As XmlNode In xdoc.SelectNodes("//category")
    Console.WriteLine(node.Attributes("name").Value)
Next

hope you got it
 
Share this answer
 
I made the solution


VB
Dim s As String = ""

Dim doc As New XmlDocument()
doc.LoadXml(testxml.InnerXml)
reader = New XmlNodeReader(doc)
While reader.Read()
      Select Case reader.NodeType
      Case XmlNodeType.Element
          s = reader.Name
      If s = "Documento" Then
         Dim Attribute As String = ""
         Attribute = reader.GetAttribute("ID")
         MsgBox("Document ID =" + AtTribute)
     End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900