Oleg Subachev wrote:
I need to read XML file, transform it and then save in the same encoding.
XmlDocument class naturally has no encoding-related members.
If the XML document has an XML declaration with an encoding specified
then xmlDocument.FirstChild is the XmlDeclaration node and has a
property named Encoding:
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"file.xml");
if (xmlDocument.FirstChild.NodeType == XmlNodeType.XmlDeclaration) {
Console.WriteLine("Encoding is: \"{0}\".",
((XmlDeclaration)xmlDocument.FirstChild).Encoding) ;
}
else {
Console.WriteLine("No XML declaration found.");
}
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/