display XML in vb Form

Hi all
In Mexico the invoices come in xml,
how do i made a visualizor in VB.NET who allow the users visualize the data may be in a windows form
is any way to achive that
tsm you experts
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi  edo60;

Parse the XML document to retrieve the elements of the document and place them in to text boxes.

You will need to know all the possible elements that can be in the document and which elements can sometimes not show up in it.
käµfm³d 👽Commented:
Well what do you mean by "visualize"? If you just want to display the XML itself, you could use the WebBrowser control.
ErnestoAuthor Commented:
yes display,
but some order, only the data that is important, not the xml syntax
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Fernando SotoRetiredCommented:

To your statement, "But some order, only the data that is important, not the XML syntax", well then you need to do what I stated in my first post. Without a sample XML file we can not be more specific.
ErnestoAuthor Commented:
All the XML that contain invoices has the same structure that is.
Fernando SotoRetiredCommented:

This is a complex XML document you wish to parse. If you are wishing to get access to certain values that will not be difficult to do but if you are looking to get all the attributes and element values for all the nodes then you will need to start at the Root node and write a recursive function to traverse the tree accessing all the nodes and retrieve there values. I have provided a function showing how to access the document but you will need to develop a recursive function to do what you need.

Imports System.Xml.Linq

'' Change to point to your document
Dim xdoc As XDocument = XDocument.Load("C:\Working Directory\1667-0.xml")
'' This is not being used in the code below but because you document 
'' uses XNamespace I am showing how to get it
Dim cfdi As XNamespace = xdoc.Root.Name.Namespace

Dim results = From node In xdoc.Root.Elements()
              select node
For Each node As XElement In results 
    If node.HasAttributes Then
        For Each attrib As XAttribute in node.Attributes()
            Console.WriteLine("    " + attrib.Name.ToString() + " = " + attrib.Value)
        If node.HasElements Then
            For Each child As XElement in node.Elements()
                Console.WriteLine("      " + child.Name.LocalName)
                For Each attrib As XAttribute In child.Attributes()
                   Console.WriteLine("        " + attrib.Name.ToString() + " = " + attrib.Value)
        End If
    End If

Open in new window

Sample output for above code.

    rfc = PEEM650712JF6
        calle = SIMONARD
        noExterior = 166
        colonia = AVIACION C
        localidad = MEXICO
        municipio = Venustiano Carranza
        estado = Distrito Federal
        pais = M跩co
        codigoPostal = 15740
        Regimen = REGIMEN INTERMEDIO
    rfc = LIN011023H80
    nombre = PATITO SA
        calle = PRESA TEPU
        noExterior = 32
        noInterior = INT. 203
        colonia = COL. LOMA 
        localidad = MEXICO
        municipio = ,varo Obregestado= DistritoFederal
        pais = Mixco
        codigoPostal = 11200
    totalImpuestosTrasladados = 112.00

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ErnestoAuthor Commented:
fernando, the output for the code is a windows form?
in need to paste the code in the form_load section?
ErnestoAuthor Commented:
i have an error in here

 Dim results = From node In xdoc.Root.Elements()

Error      22      No se puede consultar una expresión de tipo 'System.Collections.Generic.IEnumerable(Of System.Xml.Linq.XElement)'. Compruebe que no falta ninguna referencia de ensamblado ni ninguna importación de espacio de nombres para el proveedor LINQ.
Fernando SotoRetiredCommented:
It is code that will work in a win form application.

I do not read Spanish so please translate error statement when posting.

Did you add the Imports statement as shown in the first code snippet?
ErnestoAuthor Commented:
Ok fernando, the error were:

Error      22      No se puede consultar una expresión de tipo 'System.Collections.Generic.IEnumerable(Of System.Xml.Linq.XElement)'. Compruebe que no falta ninguna referencia de ensamblado ni ninguna importación de espacio de nombres para el proveedor LINQ.

Can not consult an expression from the type  'System.Collections.Generic.IEnumerable(Of System.Xml.Linq.XElement)' be sure that not reference is missing also no space importation of names for the LINQ providor
Fernando SotoRetiredCommented:
Did you add the following line to the code file at the top?

Imports System.Xml.Linq
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.