I have to read a very simple XML file that has "no namespace" and only two nodes /error/code /error/message. I have no control over the XML...this is what FedEx provides to me.
This is my xml response.
<ReplyHeader></ReplyHeader>
<Error><Code>00531</Code>
<Message>This transaction failed due to insufficient identification - account number and meter number. Please go to
www.fedex.com/us/developer/migration.html regarding upgrading to FedEx Web Services or contact your software provider.
</Message>
</Error>
Throws the error: Thread was being aborted via this code. Everything up to this line of code is fine. I don't understand how to get around this error.
Try
HttpContext.Current.Response.Write(XmlDoc.SelectSingleNode("error/code").InnerText & "<br>")
HttpContext.Current.Response.End()
Catch ex As Exception
End Try
<ReplyHeader></ReplyHeader>
<Error><Code>00531</Code>
<Message>This transaction failed due to insufficient identification - account number and meter number. Please go to
www.fedex.com/us/developer/migration.html regarding upgrading to FedEx Web Services or contact your software provider.
</Message>
</Error>
Hello,
There's a syntax wrong with your xml file——You should at least have a root tag for your xml content,something looks like this:
<Root>
<ReplyHeader>Header</ReplyHeader>
<Error>
<Code>00531</Code>
<Message>This transaction failed due to insufficient identification - account number and meter number. Please go to www.fedex.com/us/developer/migration.html regarding upgrading to FedEx Web Services or contact your software provider.
</Message>
</Error>
</Root>
And then you can use XmlDocument or XDocument to loop and check the specific node element and fetch out its value.
codeaholic
Participant
1367 Points
707 Posts
SelectSingleNode: Thread was being aborted.
Nov 08, 2012 09:54 PM|LINK
I have to read a very simple XML file that has "no namespace" and only two nodes /error/code /error/message. I have no control over the XML...this is what FedEx provides to me.
This is my xml response.
<ReplyHeader></ReplyHeader>
<Error><Code>00531</Code>
<Message>This transaction failed due to insufficient identification - account number and meter number. Please go to www.fedex.com/us/developer/migration.html regarding upgrading to FedEx Web Services or contact your software provider.
</Message>
</Error>
Throws the error: Thread was being aborted via this code. Everything up to this line of code is fine. I don't understand how to get around this error.
Try
HttpContext.Current.Response.Write(XmlDoc.SelectSingleNode("error/code").InnerText & "<br>")
HttpContext.Current.Response.End()
Catch ex As Exception
End Try
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: SelectSingleNode: Thread was being aborted.
Nov 10, 2012 12:52 AM|LINK
Hello,
There's a syntax wrong with your xml file——You should at least have a root tag for your xml content,something looks like this:
And then you can use XmlDocument or XDocument to loop and check the specific node element and fetch out its value.