我有一個包含此數據的XmlElement
:如何獲取XmlElement中的屬性值?
<message from="[email protected]/admin" to="[email protected]/Jabber.Net" type="groupchat" id="e83Dn-53" xmlns="jabber:client">
<body>:d</body>
<x xmlns="jabber:x:event">
<offline />
<delivered />
<displayed />
<composing />
</x>
<delay stamp="2013-08-07T16:53:32.693Z" xmlns="urn:xmpp:delay" from="[email protected]/Spark 2.6.3" />
<x stamp="20130807T16:53:32" xmlns="jabber:x:delay" from="[email protected]/Spark 2.6.3" />
</message>
我想獲得的屬性值stamp
和from
的delay
元素中。我已經嘗試了幾個XPath,但我不知道如何使用它,或者我必須聲明一個名稱空間。
你會考慮使用XElement(Linq to XML)嗎?然後它只是XElement.Attribute(「Key」)。值 – Jonesopolis