Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parsing XML

Posted on 2013-11-26
1
Medium Priority
?
314 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 19

Accepted Solution

by:
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

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses

926 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