reading an attribute from an XML

Posted on 2006-04-10
Last Modified: 2013-11-19
How do I read the value of the BookStatusCode  attribute using VB 6 on the XML below.  
This is the code that i have so far for that part:

Dim oXMLDoc          As DOMDocument40
Dim oXMLDomNode      As IXMLDOMNode        
Set oXMLDoc = New DOMDocument40
bValidXML = oXMLDoc.loadXML(aRequestXML)


******************This is a sample of the XML***************************
            <Loan="CONSUMER" schemaVersion="11.0.0" trackingNumber="001500001">
                        <BookCode="PENDING" BookStatusCode="INITIATED" classCode="OPEN" >
                                                                 <CustomerProfile customerRole="APPLICANT" member="TRUE" prefillStatus="SUCCESS" roleConsent="TRUE">
                                                <firstName prefillValue="exmaple">exmaple</firstName>
                                                <lastName prefillValue="exmaple">exmaple</lastName>
                                                <middleName prefillValue="A">A</middleName>

Thanks a lot,
Question by:chicho12
    LVL 52

    Accepted Solution

    Something like:

        Dim oNode As IXMLDomNode
        Set oNode = oXMLDoc.selectSingleNode("/BizTalk/Body/Loan/TransferRequest/BookCode")

        MsgBox oNode.attributes.getNamedItem("BookStatusCode").Text

    Although, the XML you posted is badly formed. Either that was a typo, or you need to revise your XML.

    For example, this line: <BookCode="PENDING" BookStatusCode="INITIATED" classCode="OPEN" >

    is invalid. You cannot have ="PENDING" on a node name, it needs to be an attribute.

    Author Comment

    It works,



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now