Convert xml file encoding UTF-8 to ANSI
I have a Word开发者_高级运维Press xml data file encoding with utf-8. But the WordPress impoter recognizes "Invalid file - Please upload a valid WXR (WordPress eXtended RSS) export file". So, i copy all text in the xml file and paste into Notepad++, then i save as a new xml file (encoding was: ANSI). But now, i import the new xml file to WordPress and there are no problem!
What's wrong with WordPress RSS encoding UTF-8? And how to convert a xml file encoding UTF-8 to ANSI using C#? Thanks for reading! :)
It's unlikely that WordPress is cranky about UTF-8. Maybe it is cranky about a BOM (byte order mark). You can supress the BOM in your XmlWriter thus:
XmlWriterSettings settings = new XmlWriterSettings();
// supress BOM since it confuses many parsers
settings.Encoding = new UTF8Encoding(false);
using (XmlWriter writer = XmlWriter.Create(path, settings)) {
...
}
精彩评论