G
George
Hello,
I have some XML that is returned to my application from another vendor that
I cannot change before it gets to me. I can only alter it after it gets to my
application. That being said, I am having a problem loading the XML correctly
into my app.
Here is the code:
====================================
Dim sPaymentXML as String
sPaymentXML = Request.Form("PaymentXML").ToString
'Create the XML Document
Dim xmlDoc As XmlDocument
xmlDoc = New XmlDocument()
'Load the Xml file
xmlDoc.LoadXml(sPaymentXML)
====================================
Whenever I run this code, it fails on the last line and gives an error of
something like:
The data at the root level is invalid. Line 1, position 1.
I believe this is because something is off in the XML. So, I am attempting
to replace the quotes that are in the XML doc with anything, but when the
code runs, it just ignores the Replace command, and after several different
attempts, I cannot get the code to recognize the double quotes that need to
be replaced.
Here is the code I add for replacing the quotes in the XML:
'Replace the quotes
sPaymentXML = sPaymentXML.Replace("""", "blah")
I have also tried outputting the XML directly to a Label on the screen so I
can examine it and it is completely valid. I have even copied the xml that
appeared in the Label, and pasted it into VisualStudio, and run the LoadXML
code again using the newly pasted code, and that works.
Any ideas??
I have some XML that is returned to my application from another vendor that
I cannot change before it gets to me. I can only alter it after it gets to my
application. That being said, I am having a problem loading the XML correctly
into my app.
Here is the code:
====================================
Dim sPaymentXML as String
sPaymentXML = Request.Form("PaymentXML").ToString
'Create the XML Document
Dim xmlDoc As XmlDocument
xmlDoc = New XmlDocument()
'Load the Xml file
xmlDoc.LoadXml(sPaymentXML)
====================================
Whenever I run this code, it fails on the last line and gives an error of
something like:
The data at the root level is invalid. Line 1, position 1.
I believe this is because something is off in the XML. So, I am attempting
to replace the quotes that are in the XML doc with anything, but when the
code runs, it just ignores the Replace command, and after several different
attempts, I cannot get the code to recognize the double quotes that need to
be replaced.
Here is the code I add for replacing the quotes in the XML:
'Replace the quotes
sPaymentXML = sPaymentXML.Replace("""", "blah")
I have also tried outputting the XML directly to a Label on the screen so I
can examine it and it is completely valid. I have even copied the xml that
appeared in the Label, and pasted it into VisualStudio, and run the LoadXML
code again using the newly pasted code, and that works.
Any ideas??