tags:

views:

36

answers:

2

If you have an XElement obj how do you get the tag name of the xelement object?

doc.Descendants("name").Where(x => (string) x == cit.name).FirstOrDefault().Parent

i would like to get the tagname of this xelement object.

A: 

doc.Descendants("name").Where(x => (string) x.Attribute("") == cit.name).FirstOrDefault().Parent

Pramodh
A: 

Once you have the right XElement, you can use Name property like so:

<someNamespace:someElement attr="blah"/>

string name = element.Name.LocalName;
//will get "someElement"
Igor Zevaka