Solved

if conditions in xpath

Posted on 2009-07-13
3
1,086 Views
Last Modified: 2013-11-11
Hi Experts

I have this xml file

<root>
      <row class="row1">
            <tr class="col1">cnn</tr>
            <tr class="col2">news</tr>
      </row>
      <row class="row2">
            <tr class="col1">amazon</tr>
            <tr class="col2">books</tr>
      </row>
</root>

I want one xpah query which returns me true or false, or that returns me the row which it's col1 value is amazon and it's seconds column value is books.

Thanks
<root>
	<row class="row1">
		<tr class="col1">cnn</tr>
		<tr class="col2">news</tr>
	</row>
	<row class="row2">
		<tr class="col1">amazon</tr>
		<tr class="col2">books</tr>
	</row>
</root>

Open in new window

0
Comment
Question by:aquasw
[X]
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
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 24839374
/root/row[tr[@class = 'col1'] = 'amazon'][tr[@class = 'col2'] = 'books']
0
 

Author Comment

by:aquasw
ID: 24840042
Thanks

But I need to check also the class type of the row
 
in such case it should be

/root/row[class="row2"]][tr[@class = 'col1'] = 'amazon'][tr[@class = 'col2'] = 'books']  ?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24841324
no class is an attribute, so you will need an extra @
/root/row[@class='row2']][tr[@class = 'col1'] = 'amazon'][tr[@class = 'col2'] = 'books']
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

631 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