xml namespace invalid

hi i am made a xml document buy i recive invalid namespace in
root = xml.AppendChild(xml.CreateElement(“cfdi:Comprobante”))
if i remplace in
root = xml.AppendChild(xml.CreateElement(“Comprobante”))
i don get any problem, but is necesary that name include cfdi: what i can do ?

Dim xml As New XmlDocument

Dim root As XmlNode

// Add the Processing Instruction to the XML document
Dim xpi As XmlProcessingInstruction
xpi = xml.CreateProcessingInstruction(“Target”, “Data”)
xml.AppendChild(xpi)
// aqui creamos el nodo
root = xml.AppendChild(xml.CreateElement(“cfdi:Comprobante”))
root.SetAttribute(“xmlns:xsi”,“http://www.w3.org/2001/XMLSchema-instance”)
root.SetAttribute(“xsi:schemaLocation”,“http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd”)
root.SetAttribute(“xmlns:cfdi”,“http://www.sat.gob.mx/cfd/3”)
root.SetAttribute(“version”,“3.2”)

You have to define the cdfi name space on your first use of it:

dim x as new XmlDocument x.AppendChild x.CreateProcessingInstruction("Target","Data") x.AppendChild x.CreateElement("http://www.sat.gob.mx/cfd/3","cfdi:Comprobante") x.DocumentElement.SetAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance") x.DocumentElement.SetAttribute("xsi:schemaLocation","http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd" ) x.DocumentElement.SetAttribute("version","3.2")

what your are searching is:
x.AppendChild x.CreateElement("http://www.sat.gob.mx/cfd/3","cfdi:Comprobante")

Now that you have the node you can define other name space:

x.DocumentElement.SetAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")

and then you can use this new one:

x.DocumentElement.SetAttribute("xsi:schemaLocation","http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd" )