日期:2014-05-16 浏览次数:21223 次
try
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(@"D:\Users\XMLFile1.xml");
Console.WriteLine("LoadXML ok");
XmlElement element = doc.DocumentElement;
string text=FormatText(element,""," ");
Console.WriteLine(text);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
<?xml version="1.0" encoding="utf-8" ?>
<stories>
<story>
<title>A House in Aungier Street</title>
<author>
<name>Sheridan Le Fanu</name>
<nationality>Irish</nationality>
</author>
<rating>eerie</rating>
</story>
<story>
<title>The Signalman</title>
<author>
<name>Charles Dickens</name>
<nationality>English</nationality>
</author>
<rating>atmospheric</rating>
</story>
<story>
<title>The Turn of the Screw</title>
<author>
<name>Henry James</name>
<nationality>American</nationality>
</author>
<rating>a bit dull</rating>
</story>
</stories>