Solved

if conditions in xpath

Posted on 2009-07-13
3
1,081 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

21 Experts available now in Live!

Get 1:1 Help Now