SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot zalucius's Avatar
    Join Date
    Jul 2007
    Location
    Denmark
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML / C#, select node based on FirstChild.Value

    Greetings,

    Im currently working with XML / C#, and have run into a little problem.

    I have this xml document:
    Code XML:
    <?xml version="1.0" encoding="utf-8" ?>
    <users>
    	<user id="1">
    		<login>Admin</login>
    		<password>1234</password>
    		<levels_id>3</levels_id>
    	</user>
    	<user id="2">
    		<login>Super</login>
    		<password>1234</password>
    		<levels_id>2</levels_id>
    	</user>
    </users>

    I want to select a single node "user" where "/user/login" = "Admin"

    I know how to select a node based on attributes (xpath), but cannot figure out how to select the node based on a child value...

    Any suggestions would be much appreciated.
    zalucius

  2. #2
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SelectSingleNode(@"/users/user[login='Admin']");

  3. #3
    SitePoint Zealot zalucius's Avatar
    Join Date
    Jul 2007
    Location
    Denmark
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah.. I figured it would be that simple, just thought that only worked on attributes, and not childnodes...

    Thanks.
    zalucius


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •