c# - How to get attribute values inside an XmlElement? -


i have xmlelement containing data:

<message from="smithfamily@conference.hp63008-y57/admin" to="admin@hp63008-y57/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="admin@hp63008-y57/spark 2.6.3" />      <x stamp="20130807t16:53:32" xmlns="jabber:x:delay" from="admin@hp63008-y57/spark 2.6.3" />  </message> 

i attributes values stamp , from inside delay element. have tried several xpaths don't know how use or if have declare namespace.

use xelement instead. save lot of time , effort.

xelement xmlroot = xelement.load("somefile.xml"); xelement xmlroot = xelement.parse("somexmlstring");  string stampvalue = xmlroot     .element("delay")     .attribute("stamp")     .value;  string fromvalue = xmlroot     .element("delay")     .attribute("from")     .value; 

if have more 1 element use elements, should basics of need.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -