简体   繁体   中英

Error in processing special symbols XML C#

enter image description here I process xml-documents using XmlDocument in C#:

XmlDocument xml = new XmlDocument ();    
xml.Load(file);

I have faced the following problem:

In a number of documents there is a special symbol: &#167 (it is a symbol § )

It isn't distinguished while processing and so the document doesn't open in Word. (Word error when processing the XML file. Inadmissible sign XML)

It would be desirable that after processing symbols &#167 remained on the places.

May be someone know how to solve this problem?

This is a detailed microsoft article on how to do this. Essentially you will need to load the xml file and replace the special characters using StreamWriter.

https://support.microsoft.com/en-us/kb/316063

The &#167 is not symbol §

The § is symbol §

The xml file will ivalid if there is something like &#167 . It have to be § One of possible solution is read the file just like a text then replace all &#167 to § , save and finally open it as xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM