I'm working with XML data from an application where we get XML like this:
<elt attrib="Swedish: ä ö Euro: € Quotes: ‘ ’ “ ”">
Swedish: ä ö Euro: € Quotes: ‘ ’ “ ”
</elt>
I want the attribute value and inner text values to be
Swedish: ä ö Euro: € Quotes: ‘ ’ “ ”
but code like this:
Dim sXml As String = "<?xml version = ""1.0"" encoding = ""Windows-1252""?>" & vbCrLf & _
"<elt attrib=""Swedish: ä ö Euro: € Quotes: ‘ ’ “ ”"">" & _
"Swedish: ä ö Euro: € Quotes: ‘ ’ “ ”" & _
"</elt>"
Dim X As New XmlDocument
X.LoadXml(sXml)
TextBox1.Text = "Attribute: {" & X.DocumentElement.Attributes("attrib").Value & "}" & _
vbCrLf & "InnerText: {" & X.DocumentElement.InnerText & "}" & vbCrLf & _
"Length: " & Convert.ToString(Len(X.DocumentElement.InnerText))
or this:
Dim X As XDocument = XDocument.Parse(sXml)
TextBox1.Text = "Attribute: {" & X.Root.Attribute("attrib").Value & "}" & _
vbCrLf & "InnerText: {" & X.Root.Value & "}" & vbCrLf & _
"Length: " & Convert.ToString(Len(X.Root.Value))
give me:
{Swedish: ä ö Euro: Quotes: }
They both have the length correct at 36, so apparently where I want the Euro and quotes I'm getting something else, presumably based on a Unicode encoding.