XPath locate help

Posted on 2012-09-17
Last Modified: 2012-09-17
Hi, I haven't worked with XPath enough to know this one off the top of my head.

Given this XML snippet
		<add key="clientID" value="7" />
                <add key="somethingelse" value="1234" />
		<add key="clientID" value="8" />
                <add key="somethingelse" value="5678" />

Open in new window

I need to be able to locate the "appSettings" block, on a per client basis, so my XPath will specify the clientID to look for.

This is my current flawwed and very non-working example,
//appSettings[add@value="7" and add@key="clientId"]

Can someone steer me in the correct direction?
Question by:raterus
    LVL 18

    Accepted Solution

    Try this:

    //appSettings[add[@value="7" and @key="clientID"]]

    Note, the string comparisons are case-sensitive.
    LVL 33

    Author Closing Comment

    Makes complete sense when I look at it, and it works great!

    LVL 18

    Expert Comment

    You're welcome

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now