简体   繁体   中英

XDocument.Load() with special character in xml document

I know google is full of this, but I couldn't make it work after hours of trying.

So here's foo.xml:

<Root>
    <Child>a</Child>
</Root>

XDocument.Load("foo.xml") works great.

Here is bar.xml:

<Root>
    <Child>á</Child>
</Root>

XDocument.Load("bar.xml") throws a System.Xml.XmlException:

{"Invalid character in the given encoding. Line 2, position 9."}

How should I progress?

这里没有魔术,我只需要将xml编码为UTF8。

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