[英]Can I read XML Attributes dynamically in WPF C#
Hi I have one big concern about reading XML attributes like 嗨,我对读取XML属性有很大的担忧,例如
<xmlNode attribute1="somevalue1" attribute2="somevalue2" attribute3="somevalue3">
Can we read attribiute1, attribute2 or attribute3 dynamically? 我们可以动态读取attribiute1,attribute2或attribute3吗? I know we can read attribute values by
nd.Attributes["attribiute1"].Value
. 我知道我们可以通过
nd.Attributes["attribiute1"].Value
读取属性值。 but how to read this "attribute1" dynamically? 但是如何动态读取此“ attribute1”?
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 这不是专用于WPF,它在您可以访问linq to xml提供程序的地方都可以使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.