2016-04-28 5 views
0
私は、XPath使用して私のXidel出力を調整したい

からクラスを除外する方法:「AClassは」を含む行を削除することによって// BODY/DIVを、そして「MyClassの」とのラインを保つだけXidel出力

Xidel出力ファイルに改行を追加できますか?

<a class="AClass" href="http://www.mywebsite.com/file1" target="_blank"> File1 </a>  
<a class="AClass" href="http://www.mywebsite.com/file2" target="_blank"> File2 </a>  
<a class="AClass" href="http://www.mywebsite.com/file3" target="_blank"> File3 </a> 
<a class="AClass" href="http://www.mywebsite.com/file4" target="_blank"> File4 </a> 
<a class="MyClass" href="http://www.mywebsite.com/file5" target="_blank"> File5 </a> 
<a class="AClass" href="http://www.mywebsite.com/file6" target="_blank"> File6 </a> 
<a class="MyClass" href="http://www.mywebsite.com/file7" target="_blank"> File7 </a> 
+0

正確にどのXPath式を使用していますか? '// body/div'は' a'ではなく 'div'sのリストを返します。一般的に、フィルタリングは '[]'または代わりに 'except' – BeniBela

答えて

0

私たちはあなたの例では、それは//a[@class !="AClass"]だろう、定期的な不等式を使用することができますXQueryの持つ属性を除外します。

これははAClassに等しくない属性クラスを含む関係なく、深さの、全て<a>と一致。

あなたの他の質問は、xidelの出力ファイルに改行を追加することです。確かに、--output-footerまたは--output-separatorフラグを使用することが可能です。

--output-footerは、すべての出力の末尾に文字列を追加します(複数の改行など)。

--output-separatorは、各項目の最後に文字列を追加します。

関連する問題