Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
string data=<item><name>pradeep</name></item>
XmlDocument doc = new XmlDocument();
    doc.LoadXml(data);


how to dispaly the value into a textbox.....
Posted
Updated 7-Jun-11 4:54am
v2
Comments
Morl99 7-Jun-11 11:00am    
what do you want to do? What is your problem? The Parsing of the XML Document? Or the displaying of the value?
Sandeep Mewara 7-Jun-11 11:42am    
What is the issue? It can be directly assigned to the textbox.
Sergey Alexandrovich Kryukov 7-Jun-11 15:04pm    
No issue report.
--SA

 
Share this answer
 
 
Share this answer
 
C#
string data = "<item><name>pradeep</name></item>";
XmlDocument xmlDoc = new XmlDocument();
//XmlDocument won't parse the string data as XmlDeclaration is missing. Hence below is the correct xml format.
string completeXML = "<?xml version=\"1.0\"?>" + data;
xmlDoc.LoadXml(completeXML);
//using XPath expression to get to the name node
string xPath = "/item/name";
XmlNode node = xmlDoc.SelectSingleNode(xPath);
textBox1.Text = node.InnerText;


You can learn about XPath here: http://www.w3schools.com/XPath/default.asp[^].
 
Share this answer
 
Comments
kumar2233 9-Jun-11 5:18am    
iam try this solution.
my xml format like this <XMLPayResponse xmlns="http://www.paypal.com/XMLPay"><responsedata><vendor>mudiaminc<Partner>paypal</Partner><TransactionResults><TransactionResult><result>0<iavsresult>N<avsresult><streetmatch>Match<zipmatch>No Match<message>Approved<PNRef>V35A0B31EC2D</PNRef><authcode>276PNI</TransactionResult></TransactionResults></XMLPayResponse>.

in the above example i try this..

its getting error.
Tarun.K.S 9-Jun-11 10:02am    
The XML is not well structured. Can you give a better one?

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