2010-11-17 80 views
0

嗨 我有一个像下面如何格式化xml?

<Root><First><id></id></First><Second><a>a</a><b>b</b></Second></Root> 

我必须把它格式化为

<Root><First><Second><a>a</a><b>b</b></Second><id></id></First></Root> 

一个xml任何一个可以告诉我怎么做这在C#2.0。 ?

+1

这两个XML片段并不等同。你想移动''内的''元素? – 2010-11-17 06:13:02

+0

是的。第二个XML片段是预期的。 – Pradeep 2010-11-17 06:21:20

回答

0

它使用XML转换,我认为是很简单的,如果你做这样的事会工作: http://www.logiclabz.com/c/net-c-function-to-convert-xml-document-into-html-string-using-xslt.aspx

如果不知道这一点,我觉得你有一个很好的机会和你一起学习它的问题 - 这是很强大!

+0

我需要一个可以使用c#2.0解决的解决方案。 – Pradeep 2010-11-17 06:22:56

+0

然后可能:http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63 – 2010-11-17 06:25:24

+0

即使编译版本看起来像它也存在于2.0中:http://msdn.microsoft.com/ EN-US /库/ system.xml.xsl.xsltransform%28V = VS.80%29.aspx – 2010-11-17 06:35:30

0

尝试使用DOM来转换节点。