EDN Admin
Well-known member
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
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