Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

XPath Expression

Posted on 2006-06-29
1
538 Views
Last Modified: 2008-03-10
Hi Experts,

I have an XML as follows:

<employee>
<emp>
      <name dptid=1>xyz</name>
      <design>manager</design>
      <sal>20000</sal>
 </emp>
<emp>
      <name dptid=2>abc</name>
      <design>engineer</design>
      <sal>10000</sal>
 </emp>
<emp>
      <name dptid=1>def</name>
      <design>engineer</design>
      <sal>12000</sal>
 </emp>
</employee>

I am using xerces DOMParser with XPath in Java to fetch the nodes.

Now, I want to fetch all the “emp” nodes where the ‘dptid=1’ in the node ‘name’. Could you help me to write the expression in XPath to achieve this?

Thanks & Regards
Vijay T. Prabakar
0
Comment
Question by:CIPL-Senthil
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 250 total points
ID: 17016036
Hi CIPL-Senthil,

//emp[name/@dptid='1']

Cheers!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Scraping specific data within an XML document 19 59
XML XSL Message 3 28
Powershell XML in variable 4 25
Powershell import xml to array (non-cli xml) 4 18
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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