Skip to content

Instantly share code, notes, and snippets.

@witoong623
Created April 6, 2015 16:40
Show Gist options
  • Save witoong623/6ed4d355b0b4fc18b6f3 to your computer and use it in GitHub Desktop.
Save witoong623/6ed4d355b0b4fc18b6f3 to your computer and use it in GitHub Desktop.
the code that use for load xml file with specific encoding
using System;
using System.Text;
using System.IO;
using System.Xml;
namespace testParseXml1
{
class Program
{
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
Parse();
Console.ReadKey();
}
private static void Parse()
{
var doc = new XmlDocument();
string xmlText = File.ReadAllText("kanjidic2.xml", Encoding.Default);
doc.LoadXml(xmlText);
}
}
}
@ryanvs
Copy link

ryanvs commented Apr 7, 2015

Try putting try/catch around the doc.LoadXml() method and checking the exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment