如何删除字符串< string xmlns =" http://schemas.microsoft.com/2003/10/Serialization/">在xml中使用xslt [英] How to remove string <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"> in xml with xslt
问题描述
感谢您阅读我的问题......
我正在努力将一个xml转换为另一个xml xslt。
以下是我的代码。
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; StringBuilder的OSB =新的StringBuilder();
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP; XmlDocument的XDOC =新的XmlDocument();
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP; xDoc.LoadXml(的 sSourceXML 强>);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; XslCompiledTransform myXslTrans =新XslCompiledTransform();
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP; myXslTrans.Load(的 sXsltPath 强>);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; System.IO.StringWriter SW =新System.IO.StringWriter(OSB);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; XmlTextWriter的myWriter =新的XmlTextWriter(SW);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP; myXslTrans.Transform(XDOC,NULL,myWriter);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; return oSB.ToString();
我得到的结果xml低于字符串。
< string xmlns =" http://schemas.microsoft.com/2003/10/Serialization/">
我希望在我的结果xml中删除字符串以上..
你能告诉我怎么做......
AnilJayanti
如果要更改XSLT代码而不是输出该命名空间,那么我们需要查看您的XSLT代码。它可能只是有例如。
< XSL:样式表的xmlns:XS = QUOT; HTTP://www.w3.org/1999/XSL/Transform"
&NBSP;&NBSP;&NBSP;&NBSP; version =" 1.0"
xmlns =" http://schemas.microsoft.com/2003/10/Serialization/">
然后将其更改为
&NBSP; < XSL:样式表的xmlns:XS = QUOT; HTTP://www.w3.org/1999/XSL/Transform"
&NBSP;&NBSP;&NBSP;&NBSP; version =" 1.0">
可能就足够了。
Hi,
Thanks for reading my question...
i'm working on transforming one xml to another xml using xslt.
below is my code.
StringBuilder oSB = new StringBuilder();
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(sSourceXML);
XslCompiledTransform myXslTrans = new XslCompiledTransform();
myXslTrans.Load(sXsltPath);
System.IO.StringWriter SW = new System.IO.StringWriter(oSB);
XmlTextWriter myWriter = new XmlTextWriter(SW);
myXslTrans.Transform(xDoc, null, myWriter);
return oSB.ToString();
i'm getting a result xml with below string.
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
i want to be removed above string in my result xml..
can u show me how to do this...
AnilJayanti
If you want to change the XSLT code not to output that namespace then we need to see your XSLT code. It might simply have e.g.
<xsl:stylesheet xmlns:xs="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
and then changing that to
<xsl:stylesheet xmlns:xs="http://www.w3.org/1999/XSL/Transform"
version="1.0">
might suffice.
这篇关于如何删除字符串< string xmlns =" http://schemas.microsoft.com/2003/10/Serialization/">在xml中使用xslt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!