I am having a hard time parsing some simple xml data being sent back by a cc terminal.
Here is the data I'm given back:
"<PLCardPresent>0</PLCardPresent><PLEntryMode>1</PLEntryMode><PLNameOnCard>FRANKINSON/FRANK </PLNameOnCard><AmountDue>0</AmountDue><TipAmount>0</TipAmount><CashBackAmout>0</CashBackAmout><MerchantFee>0</MerchantFee><TaxAmount>0</TaxAmount><ExpDate>1219</ExpDate><ECRRefNum>666</ECRRefNum>"
I am attempting to parse it with this:
Dim myXmlDoc As New XmlDocument
myXmlDoc.Load(r.ExtData)
Dim ExpDate As String = ReturnXmlValue(myXmlDoc, "ExpDate")
Dim NameOnCard As String = ReturnXmlValue(myXmlDoc, "PLNameOnCard")
My method:
Protected Function ReturnXmlValue(ByVal myXDoc As Xml.XmlDocument, ByVal field As String) As String
Dim retval As String = String.Empty
Try
Dim node As Xml.XmlNodeList = myXDoc.GetElementsByTagName(field)
If node IsNot Nothing And node.Count > 0 Then
retval = node.Item(0).InnerText
End If
Catch ex As Exception
WriteException(ex)
Throw
End Try
Return retval
End Function
The errors is happening at the load of the xml doc.
Am I not parsing this the right way?
ADDITIONAL INFO
Since it was suggested that I check for null terminators, I made the following change, which I hope is what was meant:
Dim test As String = r.ExtData.Replace(ControlChars.NullChar, String.Empty)
Dim myXmlDoc As New XmlDocument
myXmlDoc.Load(test)
I still received the error I mention in the title.
As for what is the r.ExtData, it is the line of data that starts with that I highlighted above.
Dim r As PaymentResponse = posl.PaymentResponse
Which gives me something similiar to this:

r.ExtDatathat you use to load the XML data?Loadaccepts a filename, not an XML string.LoadXmlto load from string