Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML Parsing vb using DOMDocument

Reply
Thread Tools

XML Parsing vb using DOMDocument

 
 
bird
Guest
Posts: n/a
 
      03-04-2005
?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

 
Reply With Quote
 
 
 
 
William Park
Guest
Posts: n/a
 
      03-04-2005
bird <(E-Mail Removed)> wrote:
> ?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>'

--
William Park <(E-Mail Removed)>, Toronto, Canada
Slackware Linux -- because it works.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DOMDocument MM XML 1 04-08-2008 06:35 PM
finding the memory footprint of DOMDocument muralibala68@gmail.com XML 4 11-03-2006 01:01 AM
DomDocument jty202 ASP .Net 1 01-17-2005 02:44 AM
ActiveXObject("MSXML2.DOMDocument.4.0") error K. Wilder ASP General 1 09-16-2003 05:11 AM
Saving XML DOMDocument Rinchenzo-La Javascript 3 08-30-2003 01:35 AM



Advertisments