Solved

if conditions in xpath

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

11 Experts available now in Live!

Get 1:1 Help Now