NoviceMe
NoviceMe

Reputation: 3256

How can i get name of the node only not the namespace

I have this node: . I am using LINQ query to get this node. How can i get this node but not the namespace? I tried using:

foreach(var g in xDoc.Descendants(ab + "games"){

         g.Name.ToString();
}

This gives ab(whole namespace string) also with the name. Is there a easier way to remove this?

Upvotes: 0

Views: 353

Answers (2)

Andrii Startsev
Andrii Startsev

Reputation: 767

Use XElement.Name.LocalName property.

Upvotes: 2

Diego
Diego

Reputation: 1569

You can do it using the LocalName property:

foreach(var g in xDoc.Descendants(ab + "games"){
     g.Name.LocalName;
}

Upvotes: 0

Related Questions