Page 1 of 1

Lectura de archivos XML

Posted: Wed Feb 21, 2018 8:59 pm
by andyglezl
Hola
Estoy empezando a ver el tema de poder leer un archivo XML de la factura electrónica acá en México,
alguna pista o ejemplo por donde empezar ???
Gracias.
------------------------------------------------------------------------------------------------------------------------------
Hello
I'm starting to see the issue of being able to read an XML file from the electronic invoice here in Mexico,
Some clue or example where to start???
Thank you.

Re: Lectura de archivos XML

Posted: Wed Feb 21, 2018 9:34 pm
by dragancesu
XML Is text file, easy for read, but interpreting content maybe not. Can you upload example XML?

Download program xmlpad and read XML, you can see structure, logical part of it

Re: Lectura de archivos XML

Posted: Thu Feb 22, 2018 12:34 am
by andyglezl
Gracias dragancesu por contestar.

Quiero ampliar la necesidad que tengo (a grandes rasgos).
Necesito leer uno o varios archivos XML con filtros de diferentes valores que existan en ellos,
y emitir una serie de reportes o exportar a Excel cierta información. (por supuesto, en HMG)
Según leí, necesito leer cada TAG y obtener su valor

Anexo un ejemplo de un archivo XML.
(parece que la extención XML da problemas, lo envío como .rar )

-------------------------------------------------------------------------------------------------------------------------------
Thanks Dragancesu for answering.

I want to expand the need that I have (roughly).
I need to read one or more XML files with filters of different values that exist,
and issue a series of reports or export some information to Excel. (Of course, in HMG)
As I read, I need to read each TAG and get its value

An example of an XML file is attached.
(It seems that the XML extension gives problems, I send it as. rar)

Muestra XML.rar
(2.78 KiB) Downloaded 171 times

Re: Lectura de archivos XML

Posted: Thu Feb 22, 2018 8:11 am
by dragancesu
XML can contain many logical units as in this case
but for work I think it's enough to focus on several lines that contain the data they need

Code: Select all

  <cfdi:Emisor Rfc="SASS1234569E3" Nombre="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" RegimenFiscal="621"></cfdi:Emisor>
  <cfdi:Receptor Rfc="SDT1234565C8" Nombre="yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" UsoCFDI="G01"></cfdi:Receptor>
this is like data header Emisor and Receptor record data

Code: Select all

 <cfdi:Concepto ClaveProdServ="50161800" Cantidad="1" ClaveUnidad="H87" Unidad="CAJA" Descripcion="CHUPON DEDITO" ValorUnitario="435.00" Importe="435.00" Descuento="21.75">
      <cfdi:Impuestos>
        <cfdi:Traslados>
          <cfdi:Traslado Base="413.25" Impuesto="003" TipoFactor="Tasa" TasaOCuota="0.080000" Importe="33.06"></cfdi:Traslado>
        </cfdi:Traslados>
      </cfdi:Impuestos>
    </cfdi:Concepto>
and this is records Concepto and Traslados, I think they are a logical unit and need save them into one record

The good side of the XML format is that it also contains the field name and field contents
xml.jpg
xml.jpg (86.62 KiB) Viewed 2944 times
this is screenshot of program XMLPad

Re: Lectura de archivos XML

Posted: Thu Feb 22, 2018 3:31 pm
by martingz
Andy te puedo enviar unas muestras de un lector de xml que desarrolle, es muy especifico a los datos pero te puedes dar una idea de como empezar


saludos

Re: Lectura de archivos XML

Posted: Fri Feb 23, 2018 4:35 am
by jorge.posadas
Martín,

Yo me apunto para esa "muestra de lector xml", de antemano gracias

Re: Lectura de archivos XML

Posted: Fri Feb 23, 2018 5:35 pm
by andyglezl
Thanks Dragancesu

------------------------------

Gracias Martin,

Si me interesan tus ejemplos para poder empezar

Re: Lectura de archivos XML

Posted: Fri Feb 23, 2018 8:25 pm
by martingz
Como decia es muy basico se puede mejorar bastante, pero era algo que urgia para una auditoria, no hubo tiempo de refinarlo, pueden bajarlo de este link


https://mega.nz/#!YlR0USwL!eOtG3MlWnYq5 ... OWTvx0bnGQ


saludos