在Linq中帮助使用半冒号的xml标签 [英] Help in Linq to xml-tags with semi colon
问题描述
你好朋友
你能帮我用XDocument创建这个文档吗,XElement我的意思是LINQ。我面临的问题是带冒号的中间标签。
< rss xmlns:g =http://base.google.com/ns/1.0 xmlns:receipt =urn:receipt>
< channel>
< item>
< g:id>< ; / g:id>
< g:google_product_category />
< g:image_link>
< / g:image_link> ;
< / item>< / channel>< / rss>
Hello friends
Can you please help me to create this document with XDocument,XElement i mean by LINQ. The problem i am facing is the intermediate tags with colon.
<rss xmlns:g="http://base.google.com/ns/1.0" xmlns:receipt="urn:receipt">
<channel>
<item>
<g:id></g:id>
<g:google_product_category />
<g:image_link>
</g:image_link>
</item></channel></rss>
推荐答案
嗨somnath roy24,
所以你需要这样的东西?
Hi somnath roy24,
so you need something like this?
XNamespace g = "http://base.google.com/ns/1.0";
XElement rss = XElement.Parse(@"<rss xmlns:g=""http://base.google.com/ns/1.0"" xmlns:receipt=""urn:receipt""> </rss>");
rss.Add(new XElement("channel",
new XElement("item",
new XElement(g + "id"),
new XElement(g + "google_product_category"),
new XElement(g + "image_link"),
new XElement(g + "image_link")
)));
+运算符为XNamespace重载...
The "+" operator is overloaded for XNamespace...
这篇关于在Linq中帮助使用半冒号的xml标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!