简体   繁体   中英

Can I read XML Attributes dynamically in WPF C#

Hi I have one big concern about reading XML attributes like

<xmlNode attribute1="somevalue1" attribute2="somevalue2" attribute3="somevalue3">

Can we read attribiute1, attribute2 or attribute3 dynamically? I know we can read attribute values by nd.Attributes["attribiute1"].Value . but how to read this "attribute1" dynamically?

var xml = XElement.Parse(@"your xml");
foreach (var attr in xml.Attributes())
{

}

This is not specific to WPF, it works wherever you have access to the linq to xml provider

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