我想用“KG01 Personnummer”字符串删除一个节点。然后将其保存到StringReader,有问题让它工作。
我尝试了很多东西! Plz帮助
public string ConvertXmlToHtml(string xmlCode)
{
doc.LoadXml(xmlCode);
foreach(XmlNode elem in doc.DocumentElement.ChildNodes)
{
if (elem.Name.Contains("KG01_SSN"))
{
elem.RemoveChild(elem);
}
}
xmlCode = doc.ToString();
var reader = new XmlTextReader(new StringReader(xsltCodeWhitClass));
xslCompiledTransform.Load(reader);
var xmlRead = new XmlTextReader(new StringReader(xmlCode));
using (stringWriter)
{
xslCompiledTransform.Transform((XmlReader)xmlRead, emptyArgs, stringWriter);
return whitelistedHtml = stringWriter.ToString();
}
}
答案 0 :(得分:0)
删除xmlCode = doc.ToString();
尝试
using (stringWriter)
{
xslCompiledTransform.Transform(doc, emptyArgs, stringWriter);
return whitelistedHtml = stringWriter.ToString();
}