Hello everyone

I have this XML file that has all the information for payroll, but we have a system where the employee goes and sees his payment for the week, so what i've been trying to get my head around this problem is that we need to extract some information from the xml file

I've been on this for a few days now and i cant solve it

this are the fields that i only need:
-NumEmpleado
-selloSAT
-selloCFD
-noCertificadoSAT
-UUID
-FechaTimbrado

Any help would be really appreaciate it, also i added the schemas on which that file is created.

thanks in advance

I've never used "Xml.Serialization", but the following has been tested with the XML file you provided above:

    Private Sub getEmployeeData(ByVal filename As String)
        Dim doc As New Xml.XmlDocument

        Dim numEmpleado As String = String.Empty
        Dim selloSAT As String = String.Empty
        Dim selloCFD As String = String.Empty
        Dim noCertificadoSAT As String = String.Empty
        Dim uuid As String = String.Empty
        Dim fechaTimbrado As String = String.Empty

        If Not (System.IO.File.Exists(filename)) Then
            MessageBox.Show(filename + " not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Return 'exit
        End If


        Try
            'load XML document
            doc.Load(filename)

            'set up NameSpaceManager
            Dim man As Xml.XmlNamespaceManager = New Xml.XmlNamespaceManager(doc.NameTable)

            'get the following information from the line that has
            'the following format:
            'xmlns:<prefix>=<url>

            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            'add "xsi" to namespace
            man.AddNamespace("cfdi", "http://www.sat.gob.mx/cfd/3")

            'xmlns:nomina="http://www.sat.gob.mx/nomina"
            'add "nomina" to namespace
            man.AddNamespace("nomina", "http://www.sat.gob.mx/nomina")

            'xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital"
            'add "tfd" to namespace
            man.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")

            'get "nomina:Nomina" node
            Dim xmlNominaNominaNode As Xml.XmlNode
            xmlNominaNominaNode = doc.SelectSingleNode("/cfdi:Comprobante/cfdi:Complemento/nomina:Nomina", man)


            'if xmlNominaNominaNode has attributes, read them
            If Not (xmlNominaNominaNode.Attributes Is Nothing) Then
                For Each myAttrib As Xml.XmlAttribute In xmlNominaNominaNode.Attributes

                    'Console.WriteLine("     " & myAttrib.Name & ":" + myAttrib.Value)

                    If myAttrib.Name = "NumEmpleado" Then
                        numEmpleado = myAttrib.Value
                    End If
                Next
            End If


            'get "tfd:TimbreFiscalDigital" node
            Dim xmlTfdTimbreFiscalDigital As Xml.XmlNode
            xmlTfdTimbreFiscalDigital = doc.SelectSingleNode("/cfdi:Comprobante/cfdi:Complemento/tfd:TimbreFiscalDigital", man)


            'if xmlTfdTimbreFiscalDigital has attributes, read them
            If Not (xmlTfdTimbreFiscalDigital.Attributes Is Nothing) Then
                For Each myAttrib As Xml.XmlAttribute In xmlTfdTimbreFiscalDigital.Attributes

                    'Console.WriteLine("     " & myAttrib.Name & ":" + myAttrib.Value)

                    If myAttrib.Name = "selloSAT" Then
                        selloSAT = myAttrib.Value

                    ElseIf myAttrib.Name = "selloCFD" Then
                        selloCFD = myAttrib.Value

                    ElseIf myAttrib.Name = "noCertificadoSAT" Then
                        noCertificadoSAT = myAttrib.Value

                    ElseIf myAttrib.Name = "UUID" Then
                        uuid = myAttrib.Value

                    ElseIf myAttrib.Name = "FechaTimbrado" Then
                        fechaTimbrado = myAttrib.Value
                    End If
                Next
            End If

            Dim output As String = String.Empty
            output += "numEmpleado: " & numEmpleado & System.Environment.NewLine & System.Environment.NewLine
            output += "selloSAT: " & selloSAT & System.Environment.NewLine & System.Environment.NewLine
            output += "selloCFD: " & selloCFD & System.Environment.NewLine & System.Environment.NewLine
            output += "noCertificadoSAT: " & noCertificadoSAT & System.Environment.NewLine & System.Environment.NewLine
            output += "UUID: " & uuid & System.Environment.NewLine & System.Environment.NewLine
            output += "fechaTimbrado: " & fechaTimbrado & System.Environment.NewLine

            'Console.WriteLine(output)
            MessageBox.Show(output, "XML Data")


        Catch ex As Exception
            Console.WriteLine("Error: " + ex.Message)
        End Try

    End Sub

Resources: The XML Files: Understanding XML Namespaces

Namespace Manager - "XsltContext needed" error

Edited 2 Years Ago by cgeier

The attached file contains a version using serialization (XmlSerializer). It doesn't de-serialize the complete file (I didn't have enough time to complete it), but it will de-serialize the information that you mentioned above. When I have more time, I will post an explanation here.

Usage:
deserializeFromXml()

Note: deserializeFromXml is defined in Module1.vb

I don't have a lot of time so I will give a brief description. The code I previously provided can be used for both serialization and de-serialization.

Some of the information I provide you may already know, but I will provide it for people who may not know. I've only learned about serialization in the past few days, so I will provide information base on what I have learned.

Add the following to the top of the classes that we are using:

using System.Xml.Serialization
using System.Xml.Schema

Create a class for the root element and then for each element that contains a sub-element.

Let's identify the structure of the XML file:

Root element: cfdi:Comprobante contains schemaLocation and multiple xmlns

Child Elements:

-cfdi:Complemento (Element)
    -nomina:Nomina (Element)
        -Departamento (Attribute)
        -NumEmpleado (Attribute)
        -    ...
        -nomina:Percepciones (Element)
            -TotalExento (Attribute)
            -TotalGravado (Attribute)
            -nomina:Percepcion (Element)
                -Clave (Attribute)
                -Concepto (Attribute)
                -ImporteExento (Attribute)
                -ImporteGravado (Attribute)
                -TipoPercepcion (Attribute)

    -tfd:TimbreFiscalDigital (Element) contains schemaLocation and xmlns
        -FechaTimbrado (Attribute)
        -UUID (Attribute)
        -noCertificadoSAT (Attribute)
        -selloCFD (Attribute)
        -selloSAT (Attribute)
        -version (Attribute)

*Note: During serialization/de-serialization the name of the object (class name, property name, variable name) will be used as the name of the XML object (element name, attribute name, etc...) unless otherwise specified. You can change that behavior by using "elementName:=".

Example 1:

<XmlRootAttribute(elementName:="Comprobante", Namespace:="http://www.sat.gob.mx/cfd/3", IsNullable:=False)>
Public Class Comprobante

End Class

Example 2:

<XmlElementAttribute(elementName:="Nomina", Namespace:="http://www.sat.gob.mx/nomina")>
Public Property Nomina As New ComprobanteComplementoNomina

To add schemaLocation, we use the following:

'schemaLocation
<XmlAttribute(Namespace:=System.Xml.Schema.XmlSchema.InstanceNamespace)>
Public Property schemaLocation As String = "http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd http://www.sat.gob.mx/nomina http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina11.xsd"

So it looks like this in the class:

<XmlRootAttribute(elementName:="Comprobante", Namespace:="http://www.sat.gob.mx/cfd/3", IsNullable:=False)>
Public Class Comprobante

    'schemaLocation
    <XmlAttribute(Namespace:=System.Xml.Schema.XmlSchema.InstanceNamespace)>
    Public Property schemaLocation As String = "http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd http://www.sat.gob.mx/nomina http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina11.xsd"

End Class

To add additional namespaces as specified by "xmlns", we define "xmlns" as follows:

'namespaces
<System.Xml.Serialization.XmlNamespaceDeclarations()>
Public Property xmlns As XmlSerializerNamespaces

And then use the following to add namespaces to it, in the class constructor:

'add namespaces
xmlns = New XmlSerializerNamespaces()
xmlns.Add("cfdi", "http://www.sat.gob.mx/cfd/3")
xmlns.Add("nomina", "http://www.sat.gob.mx/nomina")

So it looks like this:

<XmlRootAttribute(elementName:="Comprobante", Namespace:="http://www.sat.gob.mx/cfd/3", IsNullable:=False)>
Public Class Comprobante

    Public Sub New()

        'add namespaces
        xmlns = New XmlSerializerNamespaces()
        xmlns.Add("cfdi", "http://www.sat.gob.mx/cfd/3")
        xmlns.Add("nomina", "http://www.sat.gob.mx/nomina")

    End Sub

    'schemaLocation
    <XmlAttribute(Namespace:=System.Xml.Schema.XmlSchema.InstanceNamespace)>
    Public Property schemaLocation As String = "http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd http://www.sat.gob.mx/nomina http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina11.xsd"

    'namespaces
    <System.Xml.Serialization.XmlNamespaceDeclarations()>
    Public Property xmlns As XmlSerializerNamespaces

End Class

An attribute is defined as follows:

'attribute
<XmlAttribute(Namespace:="http://www.sat.gob.mx/cfd/3")>
Public Property certificado As String

And an element (Complemento) as follows:

    <XmlElementAttribute()>
    Public Property Complemento As New ComprobanteComplemento

Notice that Complemento is a reference to another class which we need to define: ComprobanteComplemento

ComprobanteComplemento:

Imports System.Xml.Serialization
Imports System.Xml.Schema

<XmlRootAttribute(elementName:="Complemento", Namespace:="http://www.sat.gob.mx/cfd/3", IsNullable:=False)>
Public Class ComprobanteComplemento

    Public Sub New()

        xmlns = New XmlSerializerNamespaces()
        xmlns.Add("cfdi", "http://www.sat.gob.mx/cfd/3")

    End Sub

    'namespaces
    <System.Xml.Serialization.XmlNamespaceDeclarations()>
    Public Property xmlns As XmlSerializerNamespaces

    <XmlElementAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Nomina As New ComprobanteComplementoNomina

    <XmlElementAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property TimbreFiscalDigital As New ComprobanteComplementoTimbreFiscalDigital


End Class

Edited 2 Years Ago by cgeier

TimbreFiscalDigital:

Imports System.Xml.Serialization
Imports System.Xml.Schema

<XmlRootAttribute(elementName:="TimbreFiscalDigital", Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital", IsNullable:=False), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=True, [Namespace]:="http://www.sat.gob.mx/TimbreFiscalDigital")>
Public Class ComprobanteComplementoTimbreFiscalDigital
    Public Sub New()

        'add tfd namespace
        xmlns = New XmlSerializerNamespaces()
        xmlns.Add("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")

    End Sub

    'schemaLocation
    <XmlAttribute(Namespace:=System.Xml.Schema.XmlSchema.InstanceNamespace)>
    Public Property schemaLocation As String = "http://www.sat.gob.mx/TimbreFiscalDigital http://www.sat.gob.mx/TimbreFiscalDigital/TimbreFiscalDigital.xsd"

    'namespaces
    <System.Xml.Serialization.XmlNamespaceDeclarations()>
    Public Property xmlns As XmlSerializerNamespaces

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property FechaTimbrado As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property noCertificadoSAT As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property selloCFD As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property selloSAT As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property UUID As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/TimbreFiscalDigital")>
    Public Property version As String
End Class

Notice that "TimbreFiscalDigital" uses a new "schemaLocation", so we include it in the class definition. Also, notice that the namespaces are referred to by their URI (http://...) when using "Namespace:=". This is defined using:

Public Sub New()
    xmlns.Add("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
End Sub

'namespaces
<System.Xml.Serialization.XmlNamespaceDeclarations()>
Public Property xmlns As XmlSerializerNamespaces

Also, the namespace is listed in "schemaLocation":

'schemaLocation
<XmlAttribute(Namespace:=System.Xml.Schema.XmlSchema.InstanceNamespace)>
Public Property schemaLocation As String = "http://www.sat.gob.mx/TimbreFiscalDigital http://www.sat.gob.mx/TimbreFiscalDigital/TimbreFiscalDigital.xsd"

Edited 2 Years Ago by cgeier

If you look at the xml file, you will see that "nomina:Percepcion" occurs multiple times. So, we can use a list for it. You may be able to use an array, but I had difficulty in getting the array to work, so I switched to a list:

    <XmlElementAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Percepcion As New List(Of ComprobanteComplementoNominaPercepcionesPercepcion)

The class is defined as follows:

Imports System.Xml.Serialization
Imports System.Xml.Schema

<XmlRootAttribute(elementName:="Percepciones", Namespace:="http://www.sat.gob.mx/nomina", IsNullable:=False)>
Public Class ComprobanteComplementoNominaPercepciones

    Public Sub New()

        'add namespace
        'xmlns = New XmlSerializerNamespaces()
        'xmlns.Add("nomina", "http://www.sat.gob.mx/nomina")
    End Sub

    'namespaces
    <System.Xml.Serialization.XmlNamespaceDeclarations()>
    Public Property xmlns As XmlSerializerNamespaces

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property TotalExento As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property TotalGravado As String

    <XmlElementAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Percepcion As New List(Of ComprobanteComplementoNominaPercepcionesPercepcion)

    '<XmlElementAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    'Public Property Percepcion() As New ComprobanteComplementoNominaPercepcionesPercepcion

End Class

And the class referenced by "Percepcion":

Imports System.Xml.Serialization
Imports System.Xml.Schema

<XmlRootAttribute(elementName:="Percepcion", Namespace:="http://www.sat.gob.mx/nomina", IsNullable:=False)>
Public Class ComprobanteComplementoNominaPercepcionesPercepcion

    Public Sub New()

    End Sub

    Public Sub New(ByVal Clave As String, ByVal Concepto As String, ByVal ImporteExento As String, ByVal ImporteGravado As String, ByVal TipoPercepcion As String)

        Me.Clave = Clave
        Me.Concepto = Concepto
        Me.ImporteExento = ImporteExento
        Me.ImporteGravado = ImporteGravado
        Me.TipoPercepcion = TipoPercepcion
    End Sub


    'namespaces
    <System.Xml.Serialization.XmlNamespaceDeclarations()>
    Public Property xmlns As XmlSerializerNamespaces

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Clave As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property Concepto As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property ImporteExento As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property ImporteGravado As String

    <XmlAttribute(Namespace:="http://www.sat.gob.mx/nomina")>
    Public Property TipoPercepcion As String
End Class

To read the XML file using all of the above we must use XmlSerializer.Deserialize:

Define the following:

Private filename As String = "C:\temp\CFDI2014-04-04_2014_0_13_E00003.xml"

deserializeFromXml:

    Public Sub deserializeFromXml()

        'create new instance of Comprobante class
        Dim myComprobante As New Comprobante()

        'create new instance of StreamReader
        Dim sr As New System.IO.StreamReader(filename)

        'create new instance of XmlSerializer
        Dim deserializer As New XmlSerializer(myComprobante.GetType)

        '<XmlSerializer instance>.Deserialize(<StreamReader instance>)
        myComprobante = deserializer.Deserialize(sr)

        'close StreamReader
        sr.Close()


        Console.WriteLine("NumEmpleado: " & myComprobante.Complemento.Nomina.NumEmpleado)
        Console.WriteLine("tfd:UUID: " & myComprobante.Complemento.TimbreFiscalDigital.selloSAT)
        Console.WriteLine("tfd:UUID: " & myComprobante.Complemento.TimbreFiscalDigital.selloCFD)
        Console.WriteLine("tfd:UUID: " & myComprobante.Complemento.TimbreFiscalDigital.noCertificadoSAT)
        Console.WriteLine("tfd:UUID: " & myComprobante.Complemento.TimbreFiscalDigital.UUID)
        Console.WriteLine("tfd:UUID: " & myComprobante.Complemento.TimbreFiscalDigital.FechaTimbrado)


        Console.WriteLine("nomina:Percepcion: " & myComprobante.Complemento.Nomina.Percepciones.Percepcion(0).Concepto & " " & myComprobante.Complemento.Nomina.Percepciones.Percepcion(0).Clave)
        Console.WriteLine("nomina:Percepcion: " & myComprobante.Complemento.Nomina.Percepciones.Percepcion(1).Concepto & " " & myComprobante.Complemento.Nomina.Percepciones.Percepcion(1).Clave)

    End Sub

To create an XML file (or overwrite an existing one) using XmlSerializer.Serialize:

Define the following:

Private filename As String = "C:\temp\Test.xml"

*Note: The following does not create all of the elements/attributes. It is only for demonstration/testing purposes.

serializeToXml:

    Public Sub serializeToXml()
        'create new instance of Comprobante class
        Dim myComprobante As New Comprobante()

        'create test data

        myComprobante.certificado = "MIIEbzCCA1egAwIBAgIUMDAwMDEwMDAwMDAzMDA1MTYzMTcwDQYJKoZIhvcNAQEFBQAwggGKMTgwNgYDVQQDDC9BLkMuIGRlbCBTZXJ2aWNpbyBkZSBBZG1pbmlzdHJhY2nDs24gVHJpYnV0YXJpYTEvMC0GA1UECgwmU2VydmljaW8gZGUgQWRtaW5pc3RyYWNpw7NuIFRyaWJ1dGFyaWExODA2BgNVBAsML0FkbWluaXN0cmFjacOzbiBkZSBTZWd1cmlkYWQgZGUgbGEgSW5mb3JtYWNpw7NuMR8wHQYJKoZIhvcNAQkBFhBhY29kc0BzYXQuZ29iLm14MSYwJAYDVQQJDB1Bdi4gSGlkYWxnbyA3NywgQ29sLiBHdWVycmVybzEOMAwGA1UEEQwFMDYzMDAxCzAJBgNVBAYTAk1YMRkwFwYDVQQIDBBEaXN0cml0byBGZWRlcmFsMRQwEgYDVQQHDAtDdWF1aHTDqW1vYzEVMBMGA1UELRMMU0FUOTcwNzAxTk4zMTUwMwYJKoZIhvcNAQkCDCZSZXNwb25zYWJsZTogQ2xhdWRpYSBDb3ZhcnJ1YmlhcyBPY2hvYTAeFw0xMzA3MTgxODIyNDhaFw0xNzA3MTgxODIyNDhaMIG7MR8wHQYDVQQDExZUU0UgREUgTUVYSUNPIFNBIERFIENWMR8wHQYDVQQpExZUU0UgREUgTUVYSUNPIFNBIERFIENWMR8wHQYDVQQKExZUU0UgREUgTUVYSUNPIFNBIERFIENWMSUwIwYDVQQtExxUTUU4OTAyMTU4QjIgLyBNQUFBNjMwNzI2UjM5MR4wHAYDVQQFExUgLyBNQUFBNjMwNzI2SFNSUkdSMDUxDzANBgNVBAsTBk1BVFJJWjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1dDTe6gB6d+J7HImF2T5GSRGSO3huBik1eaWvGPtugY+USptaX4dDIaoPG4q0z4ji15DPeuAKTnZPO9L9DQ5YywnleKLTX439bqGM2jyYgqRPuOg8lm0FNU4UjXJuluYWIMAaGJmMR3kKYAsKspoBUW4wA2f+pC7OgOHIp96z8kCAwEAAaMdMBswDAYDVR0TAQH/BAIwADALBgNVHQ8EBAMCBsAwDQYJKoZIhvcNAQEFBQADggEBALaF78+99N15xhVzflzyQlKYz6lrD5E43iXnapfgteih8wC8IlEczPYq0M2p/Kalc6H1EG6eqN80RssDzgG6bQpKiG7r3BucIJbvI+ceQ8UjKGxjI+9BV6z+xxZZcz8JqdZejC4dNcI6vMe+yP86RiiZ0leipvLei16afD3FLVb1H2kUZJ+hXG0i6t3gMuzMgYnLSnFALTLsfFmYtNJ8SGhC2fK70Owe4ZDJYfxLLi1RL2Op/D3KF2HC5EJ0p+UXO0Y+44W2TYA/zxIN0m4bDgehOlrl1a5yN9pPDEPLDbJ9wYVvxHgVF1Qp1eFRVk9Bvn5DtRSq55OjQoS+gXLcFTg="
        myComprobante.condicionesDePago = "CONTADO"
        myComprobante.descuento = "987.00"
        myComprobante.fecha = "2014-04-04T16:43:19"
        myComprobante.formaDePago = "PAGO EN UNA SOLA EXHIBICI""N"
        myComprobante.LugarExpedicion = "San Luis Rio Colorado, Sonora"
        myComprobante.metodoDePago = "TRANSFERENCIA ELECTRONICA"
        myComprobante.motivoDescuento = "DEDUCCIONES NÃ""MINA"
        myComprobante.noCertificado = "00001000000300516317"
        myComprobante.NumCtaPago = "86892"
        myComprobante.sello = "pQYFeVR3MP6ue2Emelpy7ZxXBd5ea7VS2AcRmsmx85kYDIGk84R+DBYHlENF/PUz5ggb3mVyrygB1AHALqjVZZBqwWn3u0NLNLYV8P3jEIAs9DvCPK9NUiK8AtWq6JWhcVgyuOJ6DugQM8mr9lDpliUvd3O6cKBEHAkaHchuxic"
        myComprobante.subTotal = "3844.00"
        myComprobante.tipoDeComprobante = "egreso"
        myComprobante.total = "2857.00"
        myComprobante.version = "3.2"

        myComprobante.Emisor.rfc = "TME8902158B2"
        myComprobante.Emisor.nombre = "TSE DE MEXICO S.A. DE C.V."

        myComprobante.Emisor.DomicilioFiscal.calle = "M DE LA MADRID Y AVE DE LA INDUSTRIA"
        myComprobante.Emisor.DomicilioFiscal.codigoPostal = "83455"
        myComprobante.Emisor.DomicilioFiscal.colonia = "PARQUE INDUSTRIAL"
        myComprobante.Emisor.DomicilioFiscal.estado = "Sonora"
        myComprobante.Emisor.DomicilioFiscal.municipio = "San Luis Rio Colorado"
        myComprobante.Emisor.DomicilioFiscal.pais = "MEXICO"


        myComprobante.Complemento.Nomina.NumEmpleado = "00003"
        myComprobante.Complemento.Nomina.NumSeguridadSocial = "21846906127"

        'create new instance of StreamWriter
        Dim sw As New StreamWriter(filename)

        'create new instance of XmlSerializer(<your class>.GetType)
        Dim serializer As New XmlSerializer(myComprobante.GetType)

        '<XmlSerializer instance>.Serialize(<StreamWriter>, <Your class name>)
        serializer.Serialize(sw, myComprobante)

        'close StreamWriter
        sw.Close()

    End Sub

This post helped me with the above.

Edited 2 Years Ago by cgeier

Also note, that for testing I made most of the data types "String". You can change them as appropriate (Decimal, Date, etc).

thanks a million cgeier!! your a Master Jedi at this =D hehehe, thanks for your help

This article has been dead for over six months. Start a new discussion instead.