c# 4.0 - C# programming to get name node from XML -


how value of node "name" below xml.

`xmldocument doc = new xmldocument(); doc.load(@"c:\new folder\sample_rajnish_1.xml"); messagebox.show(doc.selectsinglenode("confdata/cfgagentgroup/cfggroup/name").innertext);` 

below sample xml file` satrcfg_object [xml] =

<confdata>   <cfgagentgroup>     <cfggroup>       <dbid value="225"/>       <tenantdbid value="101"/>       <name value="cbd"/>       <routedndbids>         <dbid value="825"/>       </routedndbids>       <capacitytabledbid value="0"/>       <quotatabledbid value="0"/>       <state value="1"/>       <capacityruledbid value="0"/>       <sitedbid value="0"/>       <contractdbid value="0"/>     </cfggroup>     <agentdbids>       <dbid value="128"/>       <dbid value="133"/>       <dbid value="135"/>       <dbid value="385"/>       <dbid value="433"/>     </agentdbids>   </cfgagentgroup> </confdata>  

request suggestion.

thanks in advance!! rajnish

use linq xml

xelement data = xelement.load(@"c:\new folder\sample_rajnish_1.xml");  string value = data.element("cfgagentgroup").element("cfggroup")                                             .element("name")                                             .attribute("value")                                             .value; 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -