c# xml encoding — getting garbled characters

tidon

New Member
My aim here is to convert the original xml file through some xsl to the destination having a utf-8 encoding. Here is the original xml file with the following header:\[code\] <?xml version='1.0' encoding='ISO-8859-1'?>\[/code\]I'm transforming this using xsl to another xml file. The xsl file has the following header:\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan"><xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="4"/>\[/code\]Here is the C# code:\[code\] XPathDocument myXPathDoc = new XPathDocument(FileName); XslCompiledTransform myXslTrans = new XslCompiledTransform(); myXslTrans.Load("C:/test/test.xsl"); XmlTextWriter myWriter = new XmlTextWriter(destinationFile, Encoding.UTF8); myWriter.Formatting = Formatting.Indented; myWriter.Indentation = 4; myXslTrans.Transform(myXPathDoc, null, myWriter); myWriter.Close();\[/code\]The output of this is I get a garbled arabic text at destinationfile. How do get this to read proper arabic text.EDIT, Question 2:The original XML file is missing the closing root/child tags. How do I edit this xml to include these in.e.g. original xml file, missing closing for aaaa and nnnn. How do I edit using C# to get them in.\[code\]<aaaa><nnnn)<rrrr></rrrr>\[/code\]
 
Back
Top