Solved

if conditions in xpath

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
parse convert xml feed to text (python) 2 100
Excel file not created as expected 7 90
customizing windows 10 taskbar and startmenu 2 35
xml with php question 5 30
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…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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