2016-07-30 11 views
0

指定したtasgに特定のテキストが含まれている場合は、値を抽出します。Xpathが含まれている場合

入力:

<section class='question-other-answers'> 
 

 
\t <article> 
 
\t \t <div class='user' </div> 
 
\t \t 
 
\t \t <div class='details'> 
 
\t \t 
 
\t \t \t <p class='content'> 
 
\t \t \t \t exampleXYZexample 
 
\t \t \t </p> \t 
 
\t \t </div> 
 
\t \t 
 
\t \t <div class='info'> 
 
\t \t \t <div class='rating'> 
 

 
\t \t \t \t <div class='rate-up'> 
 

 
\t \t \t \t \t <a>123456789</a> 
 

 
\t \t \t \t </div> 
 
\t \t \t \t 
 
\t \t \t \t <div class='rate-down'> 
 

 
\t \t \t \t \t <a>123456789</a> 
 

 
\t \t \t \t </div> \t 
 
\t \t \t </div> 
 

 
\t \t </div> 
 
\t \t 
 

 
\t </article> 
 

 

 
</section>

私は何をしたいです:<p class='content'>XYZ

が含まれている場合、コンテンツがXYZ

が含まれている場合 エキスすべての rate-up値は、私がチェックする方法を知っています
//section[@class='question-other-answers']/article/div[2]/p and contains (.,'XYZ') 

そして、私はrate-up

//section[@class='question-other-answers']/article/div[3]/div/div[1]/a 

を取得する方法を知っている。しかし、私はそう

//section[@class='question-other-answers']/article[div[2]/p[@class = 'content' and contains (.,'XYZ')]]/div[3]/div/div[1]/a 

でどのようにそれらを組み合わせること

答えて

0

述語はノードのチェックを含めることができます見当がつかない式を結合する方法。

+0

うまく動作しません。これは、 'content'に' XYZ'があっても抽出します。これを試してみてください:http://pastebin.com/T2jLmtNw – audiophonic

+0

@audiophonic、編集を参照してください、あなたが確認したい関係をそれぞれ特定したいと思っているのは明らかです。 –

関連する問題