0

I have an application that has to parse an XML. This XML is stored in a string may contain special characters. Is there any way to clean it. I know of replace, but that would also replace the starting and ending markers ('<', '>') of the tags. A sample xml tag may be:

<Message> Employee 1&2 earned >$20,000</Message>
AnishaJain
  • 233
  • 1
  • 2
  • 13

1 Answers1

0

If the XML is manipulated correctly the result will not have those special characters. Here is what I mean:

    Dim xe As XElement =
        <root>
            <Message></Message>
        </root>

    Dim s As String = " Employee 1&2; earned >$20,000"
    xe.<Message>.Value = s

    Debug.WriteLine(xe.ToString)
    ' shows
    '<root>
    '  <Message> Employee 1&amp;2; earned &gt;$20,000</Message>
    '</root>

    Debug.WriteLine(xe.<Message>.Value)
    ' shows
    ' Employee 1&2; earned >$20,000
dbasnett
  • 11,334
  • 2
  • 25
  • 33