有没有办法XElement
从给定的 XML 字符串生成 C# 中的表示?
基本上我想要实现的是来自这样的字符串:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0">
<channel>
<title>RSS Channel Title</title>
<description>RSS Channel Description.</description>
<link>http://aspiring-technology.com</link>
<item>
<title>First article title</title>
<description>First Article Description</description>
</item>
</channel>
</rss>
像这样的字符串:
XDocument doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("rss",
new XAttribute("version", "2.0"),
new XElement ("channel",
new XElement("title", "RSS Channel Title"),
new XElement("description", "RSS Channel Description."),
new XElement("link", "http://aspiring-technology.com"),
new XElement("item",
new XElement("title", "First article title"),
new XElement("description", "First Article Description")
)
)
);
真的很感激任何提示!