用MSXML组件最好, 先安装msxml4.msi这个文件, 然后引用, 把XML文件读进来
MSXML2.DOMDocument40 LoXDoc = new MSXML2.DOMDocument40();
LoXDoc.async = false;
LoXDoc.load(StmPV.XmlPath);
下面对LoXDoc对象操作就可以了
写节点:LoXDoc.selectSingleNode("name").text ="AA"
到把数据写进去后就与xsl合成html, 写一个方法如下:
private static string XmlObjToHtml(MSXML2.DOMDocument40 LoXDoc, string XslPath)
{
MSXML2.DOMDocument40 LoXml = new MSXML2.DOMDocument40();
MSXML2.DOMDocument40 LoXsl = new MSXML2.DOMDocument40();
string StrHtml = null;
try
{
LoXml = LoXDoc;
LoXsl.async = false;
LoXsl.load(XslPath);
StrHtml = LoXml.transformNode(LoXsl);
}
catch (Exception ex)
{
LogNotes.ErrorLog("clsStmHandler:XmlObjToHtml", ex.Message);
}
AoStm = null; LoXml = null; LoXsl = null;
return StrHtml;
}
StrHtml就是你需要的html了