- Moderator
- #1
I have a table that looks something like this:
... and so forth.
SO, there may be any number of "<Lines>" in the order, then followed by bill to, ship to, etc. information.
I'm parsing the XML all right, but I'm having a problem selecting the Lines tags for a specific parent (using an index).....
I *THINK* that what I need is childNode or something along those lines.... so I essentially have a set of nested For/Next loops, something like:
... HOWEVER, before my Next, I need to then loop through the "Lines" elements and fetch all the lines (in a nested loop, obviously)... but my question is:
How do I find out how many Lines tags there are in my current item (to set another loop, for j = 0 to ??? ) and then, how do I get the information for each of them (using GetElementsByTagName.item(j).text or something similar?)
TIA!
Just my 2¢
"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."
--Greg
Code:
<Orders>
<Order>
<Lines>
<Quantity>1</Quantity>
<SKU>12345</SKU>
<UnitCost>10.00</UnitCost>
</Lines>
<Lines>
<Quantity>2</Quantity>
<SKU>23456</SKU>
<UnitCost>3.00</UnitCost>
</Lines>
<CustomerID>12345</CustomerID>
<BillToName>John Smith</BillTOName>
SO, there may be any number of "<Lines>" in the order, then followed by bill to, ship to, etc. information.
I'm parsing the XML all right, but I'm having a problem selecting the Lines tags for a specific parent (using an index).....
I *THINK* that what I need is childNode or something along those lines.... so I essentially have a set of nested For/Next loops, something like:
Code:
Set objRoot = xmlDoc.documentElement
Set oCustomer = xmlDoc.getElementsByTagName("Customer")
iNumCustomers = oCustomer.Length - 1
For i = 0 to iNumCustomers ' Loop through and do each of them separately
.... do a bunch of stuff to get the customer information using GetElementsByTagName("Whatever").item(i).text
Next
... HOWEVER, before my Next, I need to then loop through the "Lines" elements and fetch all the lines (in a nested loop, obviously)... but my question is:
How do I find out how many Lines tags there are in my current item (to set another loop, for j = 0 to ??? ) and then, how do I get the information for each of them (using GetElementsByTagName.item(j).text or something similar?)
TIA!
Just my 2¢
"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."
--Greg