Query for Lopping Xnodes to Fetch the required value

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have XML Document like
XML:
<Lists><br/>
<curve><br/>
<PS type="" out="" name="" number=" <br/>
<cdetails volt="" out="" ><br/>
<cdetails volt="" out="" ><br/>
</ps><br/>
</curve><br/>
<Fact><br/>
<PS type="" out="" name="" number=" <br/>
<cdetails volt="" out="" ><br/>
<cdetails volt="" out="" ><br/>
</ps><br/>
</Fact><br/>
</Lists>

Existing Query to fetch the value
string Num="95241245";<br/>
String cVolt="12323232";
XmlNode xNode = xmlDoc.SelectSingleNode("Lists/curve");<br/>
<br/>
foreach (XmlNode xpNode in xNode)<br/>
{<br/>
string strPowerNo = tea.Decrypt(xPNode.Attributes["number"].Value, strPassKey);<br/>
<br/>
if (strPowerNo.Equals(Num))<br/>
{<br/>
foreach (XmlNode xCurNode in xpNode)<br/>
{ <br/>
if(xCurNode.Attributes["Volt"].Value== cVolt)<br/>
{<br/>
strout = tea.Decrypt(xCurNode.Attributes["out"].Value, strPassKey);<br/>
}<br/>
}<br/>

}<br/>
}<br/>
return strout;

<br/>
here i have xmldocumet and decrypting the "Number" and checking with xmlnode and returning the "out" value...<br/>
<br/>
Now iam converting this to XDocument <br/>
<br/>
I am not getting the values using xnode<br/>
<br/>
please help me how to get the "out" value using Linq or Xpath query




<br/>
<br/>

View the full article
 
Back
Top