Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个这样的 xml:
<w:l1 xmlns:w="20130815"><w:l2 w:val = "test"/><w:l1>
如果我想访问元素w:l2,我需要知道xmlnsforw的值,但值w是动态的。
w:l2
xmlns
w
w我应该如何从 xml中获取值?
XElement l1 = .... // load or parse, then find the relevant tag XNamespace nsW = l1.GetNamespaceOfPrefix("w"); XElement l2 = l1.Descendants(nsW + "l2").First();