Error reading xml file

  • Thread starter Thread starter dianas28
  • Start date Start date
D

dianas28

Guest
Good evening, it has cost me a lot this to read xml files, but I am persistent, my problem now is that I cannot load my xml file, I feel that my failure is at the time of writing it. I leave you part of my progress.This first is so it doesn't overwrite

If IO.File.Exists("Facturas.xml") Then
Dim xmldDoc As New XmlDocument
xmldDoc.Load("Facturas.xml")

Dim mainNode As XmlNode = xmldDoc.DocumentElement
Dim newOP As XmlNode = xmldDoc.CreateElement("Facturas")

''Dim subNode As XmlNode = xmldDoc.CreateElement("Fecha")
'subNode.InnerText = lblFecha.Text
'newOP.AppendChild(subNode)

Dim subNode As XmlNode = xmldDoc.CreateElement("Factura")
newOP.AppendChild(subNode)

subNode = xmldDoc.CreateElement("CedulaJuridica")
subNode.InnerText = txtCedulaJuridica.Text
newOP.AppendChild(subNode)

subNode = xmldDoc.CreateElement("RazonSocial")
subNode.InnerText = txtRazonSocial.Text
newOP.AppendChild(subNode)

subNode = xmldDoc.CreateElement("Direccion")
subNode.InnerText = txtDireccion.Text
newOP.AppendChild(subNode)

subNode = xmldDoc.CreateElement("Provincia")
subNode.InnerText = cbProvincia.SelectedItem
newOP.AppendChild(subNode)

mainNode.AppendChild(newOP)
xmldDoc.Save("Facturas.xml")





And this is where I already write if it's not

Dim configuracionArchivo As New XmlWriterSettings

configuracionArchivo.Indent = True



Using escribiendoFactura As XmlWriter = XmlWriter.Create("Facturas.xml", configuracionArchivo)
With escribiendoFactura


'Write the xml declaration
.WriteStartDocument()
.WriteStartElement("CedulaJuridica")
.WriteString(txtCedulaJuridica.Text)
.WriteEndElement()

.WriteStartElement("RazonSocial")
.WriteString(txtRazonSocial.Text)
.WriteEndElement()

.WriteStartElement("Direccion")
.WriteString(txtDireccion.Text)
.WriteEndElement()

.WriteStartElement("Provincia")
.WriteString(cbProvincia.SelectedItem)
.WriteEndElement()

.WriteEndElement()

.WriteEndDocument()

.Close()

End With
End Using


End If

my xml file is looking like this

<Facturas>
<Factura>
<CedulaJuridica>3101162643</CedulaJuridica>
<RazonSocial>ASESORES LATINOAMERICANOS SOCIEDAD ANONIMA</RazonSocial>
<Direccion>1</Direccion>
<Provincia>Alajuela</Provincia>
</Factura>
<Facturas>
<Factura />
<CedulaJuridica>3101162643</CedulaJuridica>
<RazonSocial>ASESORES LATINOAMERICANOS SOCIEDAD ANONIMA</RazonSocial>
<Direccion>1</Direccion>
<Provincia>Alajuela</Provincia>
</Facturas>
<Facturas>
<Factura />
<CedulaJuridica>3101162648</CedulaJuridica>
<RazonSocial>CODEF S A</RazonSocial>
<Direccion>1</Direccion>
<Provincia>Cartago</Provincia>
</Facturas>
</Facturas>

Continue reading...
 
Back
Top