INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

I am having trouble figuring out ho

I am having trouble figuring out ho

(OP)
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="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32...." xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

RE: I am having trouble figuring out ho

Hi,

What have you tried?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: I am having trouble figuring out ho

(OP)
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)


RE: I am having trouble figuring out ho

(OP)
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

RE: I am having trouble figuring out ho

(OP)
Sorry sent old bit of code:

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close