Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/12/2010, 20:10
Oscargf
 
Fecha de Ingreso: junio-2010
Mensajes: 23
Antigüedad: 13 años, 10 meses
Puntos: 1
Respuesta: Crear XML para factura electronica

Por ejemplo: con este codigo

Código:
Dim doc As XmlDocument = New XmlDocument()
    Dim Nodo As XmlNode
    Const NemspaceUri As String = "http://www.w3.org/2001/XMLSchema-instance"

        Dim version As System.Xml.XmlDeclaration
        version = doc.CreateXmlDeclaration("1.0", "utf-8", "")
        version.Encoding = "utf-8"
        doc.PreserveWhitespace = True
        doc.AppendChild(version)

        Nodo = doc.CreateNode(XmlNodeType.Element, "comprobante", "http://www.sat.gob.mx/cfd/2")

        Dim Atributo1 As XmlAttribute = doc.CreateAttribute("xsi", "comprobante", NemspaceUri)
        Atributo1.Value = NemspaceUri
        Nodo.Attributes.SetNamedItem(Atributo1)

        doc.AppendChild(Nodo)

me sale esto:

Código:
<?xml version="1.0" encoding="utf-8" ?> 
<comprobante xsi:comprobante="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sat.gob.mx/cfd/2" /> 

'
como pueden ver:

1: xmlns="http//..." aparece al final en lugar de al principio
2: aparece una linea: xsi:comprobante="http://...." que no se de donde sale