简体   繁体   中英

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?

使用XElement.Name.LocalName属性。

You can do it using the LocalName property:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM