Reputation: 107
I have a xml file for example:
<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>
but, i don't know how to get beween and
the're a problem width ":" in xml node
Upvotes: 0
Views: 408
Reputation: 1502406
That shouldn't be the full XML file. There should be something specifying what the namespace alias "cd" actually means, e.g.
<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.
Upvotes: 4