Solved

Parsing XML

Posted on 2013-11-26
1
291 Views
Last Modified: 2013-11-26
I am receiving an xml response as shown.  How do I get the SubscriptionId value from the xml?

<code>

Dim post_response As String, mmsg As String, subid As String


        post_response = "<?xml version=""1.0"" encoding=""utf-8""?><ARBCreateSubscriptionResponse xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns=""AnetApi/xml/v1/schema/AnetApiSchema.xsd"">"
        post_response &= "<refId>6290</refId>"
        post_response &= "<messages>"
        post_response &= "<resultCode>Ok</resultCode>"
        post_response &= "<message>"
        post_response &= "<code>I00001</code>"
        post_response &= "<text>Successful.</text>"
        post_response &= "</message>"
        post_response &= "</messages>"
        post_response &= "<subscriptionId>1893589</subscriptionId>"
        post_response &= "</ARBCreateSubscriptionResponse>"



        BookingXML.LoadXml(post_response)

            mmsg = BookingXML.ChildNodes(1).Item("messages").FirstChild.ChildNodes(0).InnerText
           
            If UCase(mmsg) = "OK" Then
                subid = ??
            End If

</code>
0
Comment
Question by:john
1 Comment
 
LVL 18

Accepted Solution

by:
zc2 earned 500 total points
ID: 39678491
I consider that ChildNodes traversing very unreliable.
Try to use the XPath selection, it's much more convenient.

Dim nsmgr As New XmlNamespaceManager(BookingXML.NameTable)
nsmgr.AddNamespace("anet", "AnetApi/xml/v1/schema/AnetApiSchema.xsd")
subid = BookingXML.SelectSingleNode("//anet:subscriptionId", nsmgr).InnerText

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fixing Non-Standard characters in text 8 90
Display mvc partial view with errors on parent page 1 26
Cannot upload files above 1mb IIS7 11 39
Error in page 3 45
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

19 Experts available now in Live!

Get 1:1 Help Now