如何使用C#在XML文件中添加XSL样式表?
我有一个C#控制台应用程序,它运行并将以下内容添加到a文件中:如何使用C#在XML文件中添加XSL样式表?,c#,xml,xslt,C#,Xml,Xslt,我有一个C#控制台应用程序,它运行并将以下内容添加到a文件中: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <qf:VisualTemplate xmlns:qf="http://www.Qnomy.com/Templates" version="1.0" description="test doc"> <qf:Styles /> <qf:Paramete
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<qf:VisualTemplate xmlns:qf="http://www.Qnomy.com/Templates" version="1.0" description="test doc">
<qf:Styles />
<qf:Parameters />
<qf:SampleData />
<qf:Design />
</qf:VisualTemplate>
我还需要在qf:Design节点之间添加一个嵌入式xsl样式表,如下所示:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<qf:VisualTemplate xmlns:qf="http://www.Qnomy.com/Templates" version="1.0" description="test doc">
<qf:Styles />
<qf:Parameters />
<qf:SampleData />
<qf:Design>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
</xsl:stylesheet>
</qf:Design>
</qf:VisualTemplate>
是否有任何方法可以像添加XML元素一样添加带有C#的xsl样式表 根据预期的输出XML,
xsl
前缀应该绑定到”http://www.w3.org/1999/XSL/Transform“
,不要为空字符串:
.....
new XElement(ns2 + "stylesheet",
new XAttribute(XNamespace.Xmlns + "xsl", "http://www.w3.org/1999/XSL/Transform"),
new XAttribute("version", "1.0")
)
.....
根据预期的输出XML,
xsl
前缀应该绑定到”http://www.w3.org/1999/XSL/Transform“
,不要为空字符串:
.....
new XElement(ns2 + "stylesheet",
new XAttribute(XNamespace.Xmlns + "xsl", "http://www.w3.org/1999/XSL/Transform"),
new XAttribute("version", "1.0")
)
.....
.....
new XElement(ns2 + "stylesheet",
new XAttribute(XNamespace.Xmlns + "xsl", "http://www.w3.org/1999/XSL/Transform"),
new XAttribute("version", "1.0")
)
.....