Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
读取 xml 时如何将 XmlTextReader 编码设置为“windows-1252”。我不想使用 xml 中的编码。
XmlTextReader xtr = new XmlTextReader(pathToXML);
注意:我必须使用 XmlTextReader 而不是 StreamReader 以保留换行符。
StreamReader reader = new System.IO.StreamReader(pathToXML, System.Text.Encoding.GetEncoding("Windows-1252"), true); XmlTextReader xmlReader = new XmlTextReader(reader);
应该管用