Click here to Skip to main content
14,665,452 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
I have following xml
<?xml version="1.0" encoding="utf-8" ?>
<Users>
  <User>
    <UserName>Admin</UserName>
    <Password>Admin</Password>
  </User>
  <User>
    <UserName>Admin1</UserName>
    <Password>Admin1</Password>
  </User>
</Users>


How should I create my linq to xml in order to retrieve all username and passwords .
Thanks in advance
A
Posted
Comments
Pheonyx 15-Jun-13 15:40pm
   
what have you tried? have you written any code?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

var users = from nodes in System.Xml.Linq.XElement.Load(".\\..\\..\\users.xml").Elements("User") select nodes;
if (users != null)
{
foreach (var b in users)
{
string admin = b.Element("UserName").ToString();

}
}
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100