日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

Linq to xml:使用 XSLT 转换 XML 树

發(fā)布時(shí)間:2024/1/17 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linq to xml:使用 XSLT 转换 XML 树 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.


??????????? string xslMarkup = @"<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
??? <xsl:template match='/Parent'>
??????? <Root>
??????????? <C1>
??????????? <xsl:value-of select='Child1'/>
??????????? </C1>
??????????? <C2>
??????????? <xsl:value-of select='Child2'/>
??????????? </C2>
??????? </Root>
??? </xsl:template>
</xsl:stylesheet>";

??????????? XDocument xmlTree = new XDocument(
??????????????? new XElement("Parent",
??????????????????? new XElement("Child1", "Child1 data"),
??????????????????? new XElement("Child2", "Child2 data")
??????????????? )
??????????? );

??????????? XDocument newTree = new XDocument();
??????????? using (XmlWriter writer = newTree.CreateWriter())
??????????? {
??????????????? // Load the style sheet.
??????????????? XslCompiledTransform xslt = new XslCompiledTransform();
??????????????? xslt.Load(XmlReader.Create(new StringReader(xslMarkup)));

??????????????? // Execute the transform and output the results to a writer.
??????????????? xslt.Transform(xmlTree.CreateReader(), writer);
??????????? }

??????????? Console.WriteLine(newTree);

轉(zhuǎn)載于:https://www.cnblogs.com/starcrm/archive/2008/12/26/1363068.html

總結(jié)

以上是生活随笔為你收集整理的Linq to xml:使用 XSLT 转换 XML 树的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。