【发布时间】:2014-12-08 01:08:01
【问题描述】:
所以如果我有这个带有 xml 的示例字符串。
"<bookstore>
<book genre='autobiography' publicationdate='1981-03-22' ISBN='1-861003-11-0'>
<title>The Autobiography of Benjamin Franklin</title>
<author age="40">
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<author age="56">
<first-name>Barack</first-name>
<last-name>Obama</last-name>
</author>
<price>8.99</price>
</book>
</bookstore>"
我想从中制作两个不同的字符串,如下所示:
"<author age="40">
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>"
和
"<author age="56">
<first-name>Barack</first-name>
<last-name>Obama</last-name>
</author>"
因为我想把它们放在列表中。我尝试使用拆分但没有结果
【问题讨论】:
-
用 XmlDocument 打开它并循环浏览内容。
-
但这会得到值。我需要用它以字符串形式制作小的 xmls
标签: c# xml string parsing split