XML Parsing vb using DOMDocument

Discussion in 'XML' started by bird, Mar 4, 2005.

  1. bird

    bird Guest

    ?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
     
    bird, Mar 4, 2005
    #1
    1. Advertising

  2. bird

    William Park Guest

    bird <> 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 <>, Toronto, Canada
    Slackware Linux -- because it works.
     
    William Park, Mar 4, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jty202

    DomDocument

    jty202, Jan 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    531
    Peter Bromberg [C# MVP]
    Jan 17, 2005
  2. Replies:
    4
    Views:
    452
    Joe Kesselman
    Nov 3, 2006
  3. MM

    DOMDocument

    MM, Apr 8, 2008, in forum: XML
    Replies:
    1
    Views:
    497
    The Magpie
    Apr 8, 2008
  4. K. Wilder
    Replies:
    1
    Views:
    556
    Dan Brussee
    Sep 16, 2003
  5. Rinchenzo-La

    Saving XML DOMDocument

    Rinchenzo-La, Aug 26, 2003, in forum: Javascript
    Replies:
    3
    Views:
    160
    Rinchenzo-La
    Aug 30, 2003
Loading...

Share This Page