Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 8157 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > get the name of the xml nodes using in c# ...
Santosh198318

get the name of the xml nodes using in c#

Replies: 2 | Posted by: Santosh198318 on 5/9/2012 | Category: C# Forums | Views: 358 | Status: [Member] | Points: 10  


<?xml version="1.0" encoding="utf-8"?>
<Account>
<field name="name"></field>
<field name="new_accountscope"></field>
<field name="address1_line1">address1_line1</field>
<field name="address1_line2">address1_line2</field>
</account>
i have a xml ..now i have to pass the value and get the corresponding name ....please give the example in c#


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Sakthi.Singaravel
Sakthi.Singaravel  
Posted on: 5/9/2012 5:52:13 AM
Level: Silver | Status: [Member] | Points: 25

refer this article..
www.c-sharpcorner.com/uploadfile/mahesh/readwritexmltutmelll211128200504517AM/readwritexmltutmellli21.aspx

Regards,
Singaravel M

Santosh198318, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sabarimahesh
Sabarimahesh  
Posted on: 5/26/2012 8:10:20 AM
Level: Bronze | Status: [Member] | Points: 25

<Names>

<Name>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
</Name>
<Name>
<FirstName>James</FirstName>
<LastName>White</LastName>
</Name>
</Names>



C#

XmlDocument xml = new XmlDocument();

xml.LoadXml(myXmlString); // suppose that myXmlString contains "<Names>...</Names>"

XmlNodeList xnList = xml.SelectNodes("/Names/Name");
foreach (XmlNode xn in xnList)
{
string firstName = xn["FirstName"].InnerText;
string lastName = xn["LastName"].InnerText;
Console.WriteLine("Name: {0} {1}", firstName, lastName);
}


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Santosh198318, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 5:17:22 AM