1

I have an input string with a few times escaped XML inner text. E.g.:

<anode>some &amp;quot;inner&amp;quot; text</anode>

I'd like to have (in a variable) value:

some "inner" text

How can I do it in C#?

I want the solution to handle triple-encoded cases (and N-encoded cases). I.e. &amp;amp;quot; Not only &quot is interesting me, but any other encoded symbol (e.g. lt, gt etc).

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
Illia Levandovskyi
  • 1,228
  • 1
  • 11
  • 20
  • Try using search... https://stackoverflow.com/questions/6757019/how-to-decode-string-to-xml-string-in-c-sharp Then read the basics about "for", "while" or recursions (which would be too much in this case) – Woozar Mar 09 '18 at 12:44
  • there is no valid n-time encoding defined `&amp;quot;` is invalid, it should be `&&"` You have to write a decoder on your own – fubo Mar 09 '18 at 13:18
  • Use `replace` on the `InnerXml` (a string value) and replace `&quot;` with `"` If all your entities are *double escaped* it can be okay to replace any `&` with `&`. This manipulated string use to build a new document. – Shnugo Mar 09 '18 at 15:29
  • Btw: This often occurs when the entities are encoded by a self built `replace` based *engine*. Creating an XML with the appropriate tool should never bring back such bad encodings... So - if there is any chance - try to solve this when the XML is created. – Shnugo Mar 09 '18 at 15:31

0 Answers0