Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1088
  • Last Modified:

if conditions in xpath

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
aquasw
Asked:
aquasw
  • 2
1 Solution
 
Geert BormansCommented:
/root/row[tr[@class = 'col1'] = 'amazon'][tr[@class = 'col2'] = 'books']
0
 
aquaswAuthor Commented:
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
 
Geert BormansCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now