|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem loading XMLcan't load it into an Xml.XmlDocument object. However, if I take that exact same string of XML and load it up in another program, it works fine. Here's what I mean: sResponse has been received via the web and is immediately used like this: dim ParseResponse as Xml.XmlDocument ParseResponse.LoadXML(sResponse) <-- error here -- "An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll" sResponse looks like this: <?xml version='1.0' encoding='UTF-8' ?> <ns0:LALSXML xmlns:ns0="http://Client.LALS.Ack.Version1"> <Status>SUCCESS</Status> <StatusCode>SUCCESS</StatusCode> <StatusMessage></StatusMessage> <TransactionID>66d4bf32-22c8-46c1-9248-80fe280e733e</TransactionID> <ClientOrderID>060283000009-1</ClientOrderID> <ClientLineItemID></ClientLineItemID> <ReceivedDateTime>2006/24/05</ReceivedDateTime> </ns0:LALSXML> If I put that XML into a string variable in another program and then load it up the same way into an XMLDocument object, it loads fine and I can start enumerating nodes. Can anyone point me in a likely direction for a solution here? What might I be doing wrong? Matt Put a try catch around the code and recursively examine all the
exceptions that might be included. Often, the inner exceptions will tell why it is bombinb. I use code similar to this: Try 'code Catch Ex As Exception Dim s As String While Not Ex Is Nothing s &= Ex.Message & ": " & Ex.StackTrace & vbCrLf Ex = Ex.InnerException End While End Try Perhaps this will give you more information on what the problem is. I had no idea that catching exceptions would tell you more than just
examining the error as it happened in the debugger. Thanks for that. I can't believe I didn't know that. The error turns out that an XML doc (to work with the MS parser, at least) must not include ANY whitespace at all before the first line. There's an hour and a half I'll never get back. Thanks for the pointer. That actually will assuredly help me out in tons of other situations where I was getting a really vague error. Matt
Porting VB6 to .Net - DDE replacement?
Binding currencyManager and dataRelation - datagridview - possible Object from variable Question about a conversion project Need help with Conversion from C# to VB.net text align Application.Exit Inline SQL vs stored procs on SQL Server 7 and 2000 Alternate Name Looping through Dataset |
|||||||||||||||||||||||