HTML到XML的转换 [英] HTML to XML conversion
本文介绍了HTML到XML的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用C#将html转换为xml?
我的目标是从Web上获取的网页源.
UTF-16编码的XML
任何参考将不胜感激....
感谢您的帮助
how to convert an html to xml using c# ?
What I am targetting is a web page source I fetch from web.
XML in UTF-16 encoding
Any references will be appreciated....
Thanks for the help
推荐答案
几个链接-
1) http://www.example-code.com/csharp/html2xml.asp [ ^ ]
2) http://social.msdn.microsoft. com/Forums/en-US/xmlandnetfx/thread/5edb4649-2309-462e-b238-bfd4aab0bbd1 [
A couple of links -
1) http://www.example-code.com/csharp/html2xml.asp[^]
2) http://social.msdn.microsoft.com/Forums/en-US/xmlandnetfx/thread/5edb4649-2309-462e-b238-bfd4aab0bbd1[^]
示例:
使用System.Xml;
使用System.IO;
字符串temp = System.IO.File.ReadAllText("1.html");
试试
{
XmlDocument xd =新的XmlDocument();
xd.LoadXml(temp);
}
catch(例外po)
{
MessageBox.Show(您选择了错误的文件!!!");
}
Example:
using System.Xml;
using System.IO;
string temp = System.IO.File.ReadAllText("1.html");
try
{
XmlDocument xd = new XmlDocument();
xd.LoadXml(temp);
}
catch (Exception po)
{
MessageBox.Show("You have selected wrong file !!!");
}
这篇关于HTML到XML的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文