如何获取XDocument对象中的属性
我有这个xml
我希望我的代码能够做到这样的事情
if (xdoc.getAttr("first")=="true") Console.Write("first is true");
如何使用LINQ XDocument执行此操作? 到目前为止我所拥有的是用该xml字符串加载的XDocument对象。
您需要获取元素的属性:
string value = xdoc.Root.Element("audio").Attribute("first").Value;
你应该看看XElement
文章在c-sharpcorner.com