Extracting XML attribute and element name values and data values from nodes

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a XMLDOCUMENT contaning the following format:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Comprobante <span style="color:Red; xmlns:xsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema-instance<span style="color:Black; " <span style="color:Red; xmlns:cfdi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.sat.gob.mx/cfd/3<span style="color:Black; " <span style="color:Red; xsi:schemaLocation<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv3.xsd<span style="color:Black; " <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3.0<span style="color:Black; " <span style="color:Red; serie<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; M<span style="color:Black; " <span style="color:Red; folio<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 513<span style="color:Black; " <span style="color:Red; fecha<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011-06-23T16:21:15<span style="color:Black; " <span style="color:Red; sello<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; selloX<span style="color:Black; " <span style="color:Red; formaDePago<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Pago en una sola exhibición<span style="color:Black; " <span style="color:Red; noCertificado<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 100001<span style="color:Black; " <span style="color:Red; certificado<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xxxxx<span style="color:Black; " <span style="color:Red; subTotal<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 18.0000<span style="color:Black; " <span style="color:Red; Moneda<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; MXN<span style="color:Black; " <span style="color:Red; total<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 18.0000<span style="color:Black; " <span style="color:Red; metodoDePago<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Efectivo<span style="color:Black; " <span style="color:Red; tipoDeComprobante<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ingreso<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Emisor <span style="color:Red; rfc<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; DEMO000002FEL<span style="color:Black; " <span style="color:Red; nombre<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Demo2 FEL SA de CV<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; DomicilioFiscal <span style="color:Red; calle<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Privada Topacio<span style="color:Black; " <span style="color:Red; noExterior<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3505<span style="color:Black; " <span style="color:Red; colonia<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Esmeralda<span style="color:Black; " <span style="color:Red; municipio<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; MPIOE<span style="color:Black; " <span style="color:Red; estado<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ESDOR<span style="color:Black; " <span style="color:Red; pais<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; PAISE<span style="color:Black; " <span style="color:Red; codigoPostal<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 72400<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; ExpedidoEn <span style="color:Red; estado<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Estado1<span style="color:Black; " <span style="color:Red; pais<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; México<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Emisor<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Receptor <span style="color:Red; rfc<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ABX9999999N1<span style="color:Black; " <span style="color:Red; nombre<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ACADEMIA DE BELLEZA X<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Domicilio <span style="color:Red; calle<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ATENAS<span style="color:Black; " <span style="color:Red; noExterior<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 132<span style="color:Black; " <span style="color:Red; colonia<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Centro<span style="color:Black; " <span style="color:Red; municipio<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; MPIOR<span style="color:Black; " <span style="color:Red; estado<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; EDOR<span style="color:Black; " <span style="color:Red; pais<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; PAISR<span style="color:Black; " <span style="color:Red; codigoPostal<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 12345<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Receptor<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Conceptos<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Concepto <span style="color:Red; cantidad<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0000<span style="color:Black; " <span style="color:Red; descripcion<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Descuento manejo de cuenta <span style="color:Black; " <span style="color:Red; valorUnitario<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 18.0000<span style="color:Black; " <span style="color:Red; importe<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 18.0000<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Conceptos<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Impuestos <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Complemento<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; tfd<span style="color:Blue; :<span style="color:#A31515; TimbreFiscalDigital <span style="color:Red; xmlns:tfd<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.sat.gob.mx/TimbreFiscalDigital<span style="color:Black; " <span style="color:Red; xsi:schemaLocation<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.sat.gob.mx/TimbreFiscalDigital http://www.sat.gob.mx/sitio_internet/TimbreFiscalDigital/TimbreFiscalDigital.xsd<span style="color:Black; " <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; UUID<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 710F781A-7E57-7E57-7E57-432948F53DD5<span style="color:Black; " <span style="color:Red; FechaTimbrado<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 2011-06-23T16:21:15<span style="color:Black; " <span style="color:Red; selloCFD<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xxSelloCFDxx=<span style="color:Black; " <span style="color:Red; noCertificadoSAT<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 00001000000999999999<span style="color:Black; " <span style="color:Red; selloSAT<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xxSelloSATxx=<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Complemento<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; cfdi<span style="color:Blue; :<span style="color:#A31515; Comprobante<span style="color:Blue; >

[/code]
i need to retrive the following values Serie from Comprobante, Nombre from Receptor, and all attributes from Domicilio_Receptor
please help! Thanks!!!

View the full article
 
Back
Top