[英]How to read xml node contains “:”
I have a xml file for example: 我有一个xml文件,例如:
<item>
<name>John Caters</name>
<age>46</age>
<cd:creator>Wings Man</cd:creator>
</item>
And i use (string)item.Element("name").Value
to get content between <name>
and </name>
而且我使用(string)item.Element("name").Value
在<name>
和</name>
之间获取内容
but, i don't know how to get beween and 但是,我不知道如何在
the're a problem width ":" in xml node xml节点中的问题宽度为“:”
That shouldn't be the full XML file. 那不应该是完整的XML文件。 There should be something specifying what the namespace alias "cd" actually means, eg 应该有一些东西指定名称空间别名“ cd”的实际含义,例如
<doc xmlns:cd="http://something">
<item>
..
<cd:creator>...</cd:creator>
</item>
</doc>
At that point it's easy: 那时很简单:
XNamespace cd = "http://something";
string creator = (string) item.Element(cd + "creator");
... but you do need to know the namespace URL first. ...,但您确实需要首先知道名称空间URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.