Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using wcf service,in this i am getting
result = "true"


this value ,into one string variable result,i need to read only that value that is true.
how can i do this pls help me...

i am getting in the form of xml but not having xml file name...
Posted
Updated 2-Sep-11 21:51pm
v2

1 solution

What I understood from your Question is, You are calling WCF service which is returning XML string having "result" node in it. And you want to read value of "result" node from XML string.

Try as below code.
C#
string strXmlFromWCF="YourResultXMLFromWCF";//Initialize with your WCF Call.
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(strXmlFromWCF);

System.Xml.XmlNode resultNode = doc.SelectSingleNode("result");

string result = resultNode.InnerText;


Alternate Solution -

C#
string strXmlFromWCF="YourResultXMLFromWCF";//Initialize with your WCF Call.
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(strXmlFromWCF);

string result = doc.DocumentElement.InnerText
 
Share this answer
 
v2
Comments
kishore1215 3-Sep-11 4:24am    
no i dont have node result,result is a string varible which stores the that value in xml format
RaisKazi 3-Sep-11 4:41am    
Change the "xPath" in SelectSingleNode based on your XML format, Or show me your XML string.
kishore1215 3-Sep-11 5:22am    
thank u very so much,but i changed that as doc.DocumentElement.InnerText,now it works..thanks alot
RaisKazi 3-Sep-11 5:24am    
Perfect. Will update it to Solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900