Improve company productivity with a Business Account.Sign Up


Parsing XML

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


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

        post_response = "<?xml version=""1.0"" encoding=""utf-8""?><ARBCreateSubscriptionResponse xmlns:xsi="""" xmlns:xsd="""" 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>"


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

Question by:john
1 Comment
LVL 19

Accepted Solution

zc2 earned 2000 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


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

606 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