我有许多XPath,我想使用它们来创建XML文档,可能使用XmlDocument
类,并且最好利用一些现有功能,而不是以某种可能的递归方式逐节点构建循环。
给定3个xpath:
THIS/IS/FIRST/XPATH
THIS/IS/FIRST/XPATH/GOING/DEEPER
THIS/IS/SECOND/XPATH
我想制作:
<THIS>
<IS>
<FIRST>
<XPATH>
<GOING>
<DEEPER>
</DEEPER>
</GOING>
</XPATH>
</FIRST>
<SECOND>
<XPATH>
</XPATH>
</SECOND>
</IS>
</THIS>
我希望代码可以很简单地实现,并以任意顺序添加XPath:
var doc = new XmlDocument();
doc.AddXPath("THIS/IS/FIRST/XPATH");
doc.AddXPath("THIS/IS/SECOND/XPATH");
doc.AddXPath("THIS/IS/FIRST/XPATH/GOING/DEEPER");
string result = doc.ToString();`
非常感谢!
答案 0 :(得分:0)