XML Parsing vb using DOMDocument

B

bird

?sitem
<?xml version="1.0"?>
<RootNode> ' one root node
<Transaction> ' doc element node
<AccountNumber>1001000</AccountNumber> ' node list/children
<Amount>100.00</Amount>
</Transaction>
</RootNode>


Say I want to get 1001000

This is what I do in vb using the DOMDocument

Dim objDOMDocument As DOMDocument40
Dim sAccountNumber As String
Set psSendArray = New clsD3DynamicArray

' use count to find the number of items in the gl transaction
iCount = mocGLTransaction.Count


'then have to loop through each itme in the gltransaction
' Load the collection and add it to the array
'parse xml string ot populate attrs
For lx = 1 To iCount
sItem = mocGLTransaction.Item(lx)
Set objDOMDocument = New DOMDocument40
objDOMDocument.loadXML (sItem)

sAccountNumber =
objDOMDocument.selectSingleNode("RootNode/Transaction/AccountNumber").Text

Next lx

objDOMDocument.loadXML (sItem)

sAccountNumber =
objDOMDocument.selectSingleNode("RootNode/Transaction/AccountNumber").Text
 
W

William Park

bird said:
?sitem
<?xml version="1.0"?>
<RootNode> ' one root node
<Transaction> ' doc element node
<AccountNumber>1001000</AccountNumber> ' node list/children
<Amount>100.00</Amount>
</Transaction>
</RootNode>


Say I want to get 1001000

This is what I do in vb using the DOMDocument

Dim objDOMDocument As DOMDocument40
Dim sAccountNumber As String
Set psSendArray = New clsD3DynamicArray

' use count to find the number of items in the gl transaction
iCount = mocGLTransaction.Count


'then have to loop through each itme in the gltransaction
' Load the collection and add it to the array
'parse xml string ot populate attrs
For lx = 1 To iCount
sItem = mocGLTransaction.Item(lx)
Set objDOMDocument = New DOMDocument40
objDOMDocument.loadXML (sItem)

sAccountNumber =
objDOMDocument.selectSingleNode("RootNode/Transaction/AccountNumber").Text

Next lx

objDOMDocument.loadXML (sItem)

sAccountNumber =
objDOMDocument.selectSingleNode("RootNode/Transaction/AccountNumber").Text


So, what is your question? If you're seeking for XML-parsing solution,
then this is how I would parse it using Expat parser and Bash shell:

data () { # Usage: data arg
case ${XML_ELEMENT_STACK[1]} in
AccountNumber) echo "AccountNumber=$1" ;;
esac
}
xml -d data '<RootNode>...</RootNode>'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,080
Latest member
mikkipirss

Latest Threads

Top