Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am having trouble figuring out ho

Status
Not open for further replies.

squirrelman

Programmer
Jul 28, 2017
8
US
I am having trouble figuring out how to parse an xml name space file. I have an excerpt of the file below. I need to get total, fecha, folio, and serie out of the file and the normal parsing methods that I am used to programming.

You help is greatly appreciated!

<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante NumCtaPago="5008" LugarExpedicion="RAMOS ARIZPE, COAHUILA" metodoDePago="NA" tipoDeComprobante="ingreso" total="4420.64" Moneda="USD" TipoCambio="1" subTotal="3810.9" certificado="MIIGWTCCBEGgN" sello="k7YXX8ni7A==" fecha="2016-12-21T08:10:04" folio="10749" serie="A" version="3.2" xsi:schemaLocation=" xmlns:cfdi=" xmlns:xsi="
 
Hi,

What have you tried?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Well...
What I have TRIED to do is something like what is written below, but I get only the initialized values in my output.

Inv_Total = 0
Inv_Date = ""
Inv_Number = ""
Series = ""

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "True"
xmlDoc.Load(f3.path)

Set colNodes=xmlDoc.selectNodes("//cfdi/Comprobante")

For Each objNode in colNodes
Inv_Total = objNode.Attributes.getNamedItem("total").Text
Inv_Date = objNode.Attributes.getNamedItem("fecha").Text
Inv_Number = objNode.Attributes.getNamedItem("folio").Text
Series = objNode.Attributes.getNamedItem("serie").Text
Next

a.WriteLine (Inv_Total & "," & Inv_Date & "," & Inv_Number & "," & Series)


 
I do not understand your first point. I do know that all the other code runs correctly.

On your second point, when a I replace the code as you indicated I get a different error.

---------------------------
Windows Script Host
---------------------------
Script: D:\IFC\Load-Xref.vbs
Line: 95
Char: 5
Error: Object required: 'objNode.Attributes.getNamedItem(...)'
Code: 800A01A8
Source: Microsoft VBScript runtime error

---------------------------
OK
---------------------------

93 Set colNodes=xmlDoc.selectNodes("//cfdi/Comprobante")
94 For Each objNode in colNodes
95 Inv_Total = objNode.Attributes.getNamedItem("total").Text
96 Inv_Date = objNode.Attributes.getNamedItem("fecha").Text
97 Inv_Number = objNode.Attributes.getNamedItem("folio").Text
98 Series = objNode.Attributes.getNamedItem("serie").Text
99 Next

 
Sorry sent old bit of code:

93 Set colNodes=xmlDoc.selectNodes("//cfdi:Comprobante")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top