Access innerxml from XmlNode

I'm trying to access to DayOfWeek from the innerxml response.
Please see the screen shot for a better idea.

 Screen shot of debugger
Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
The result is actually an array of XmlNode
Indeed it is. I missed the parens in the SS  = )

Try the XPath:
Dim response As System.Xml.XmlNode = node.SelectSingleNode("Response/ConfirmationNumber")

Open in new window

käµfm³d 👽Commented:
Why are you storing the return from CarrierPickupRequest() in a variable of type Object? It's apparent it's an XmlNode, so why not store it as such? Then you can use its methods to extract the data.
Dim result As System.Xml.XmlNode = service.CarrierPickupRequest(xmlString)

Dim response As System.Xml.XmlNode = result.SelectSingleNode("CarrierPickupRequestResponse")

Dim innerXml As String = response.InnerXml

Open in new window

JRockFLAuthor Commented:
Thank you for your reply. That was from an earlier screen shot and I have casted it to the correct type.

I'm still not able to access the element i need.

The result is actually an array of XmlNode

        Dim result As System.Xml.XmlNode() = CType(service.CarrierPickupRequest(xmlString), System.Xml.XmlNode())
        Dim innerXml As String = String.Empty

        For Each node As System.Xml.XmlNode In result
            Dim response As System.Xml.XmlNode = node.SelectSingleNode("//CarrierPickupResponse/Response/ConfirmationNumber")
            If Not response Is Nothing Then
                innerXml = response.InnerXml
                Exit For
            End If

Here is an example response from the API
<?xml version="1.0" encoding="UTF-8"?> <CarrierPickupResponse> <AccountID></AccountID> <ErrorMsg></ErrorMsg> <Test></Test> <Response> <DayOfWeek></DayOfWeek> <Date></Date> <CarrierRoute></CarrierRoute> <ConfirmationNumber></ConfirmationNumber> </Response> </CarrierPickupResponse>
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

JRockFLAuthor Commented:
That would perfectly, thank you so much.
käµfm³d 👽Commented:
NP. Glad to help.

For future reference, the reason why yours didn't work is because at the point of calling SelectSingleNode, you were already at CarrierPickupResponse, and so you were trying to find a CarrierPickupResponse that was under a CarrierPickupResponse, which of course doesn't exist.
JRockFLAuthor Commented:
Oh, ok, that makes sense now. Thank you.
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.

All Courses

From novice to tech pro — start learning today.