mevyIndenna
New Member
i have a xml document that contains entity. when i load it and process and save then all entity get converted into UTF encoding. how to get document same as input content.Input xml is\[code\]<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE chapter SYSTEM "DTD_v1.5\PLI.dtd"> <chapter num="1" update-date="November 2012" type="chapter"> <page num="3"/> <title>Artist-Dealer Relations</title><para align="left"><content-style font-style="bold">S</content-style>i Salander-O’Reilly .</para><para>Since that time, the New York state artist consignment statute—which, </para> <para>The of the artist’s work; the amount o and the like. </para> <para>But firss of “dealer” and “gallery” interchangeably.</para> <itemizedlist type="•"> <item><para>To care </para></item></itemizedlist> <chapter>\[/code\]I want out put also same as the above xml i have try the following codes\[code\] XmlDocument xDoc = new XmlDocument(); string text = string.Empty; text = ReadFile("38149_Chapter01_Art_Law_XML.xml", enmReadType.None, Encoding.Default); xDoc.LoadXml(text); xDoc.Save("38149_Chapter01_Art_Law_XML.xml");\[/code\]and\[code\]string sXmlData = http://stackoverflow.com/questions/14516842/File.ReadAllText("38149_Chapter01_Art_Law_XML.xml", Encoding.Default); xDoc.LoadXml(sXmlData); XmlAttribute aa = xDoc.CreateAttribute("Name"); aa.Value = "http://stackoverflow.com/questions/14516842/Sarvesh"; XmlNode snode = xDoc.SelectSingleNode("//chapter"); snode.Attributes.Append(aa); using (MemoryStream ms = new MemoryStream()) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.GetEncoding("ISO-8859-1"); XmlWriter xw = XmlWriter.Create(ms, settings); xDoc.Save(xw); xw.Close(); using (TextWriter tx = new StreamWriter("38149_Chapter01_Art_Law_XML.xml", false, Encoding.Default)) { tx.Write(Encoding.UTF8.GetString(ms.ToArray())); tx.Close(); } }\[/code\]