簡體   English   中英

如何從Xidel輸出中排除類

[英]How to exclude class from Xidel output

我想使用xpath優化我的Xidel輸出: // BODY / DIV,方法是刪除包含“ AClass”的行,並僅保留帶有“ MyClass”的行

我可以在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>

要使用XQuery排除屬性,我們可以使用常規的不等式,在您的示例中,它是//a[@class !="AClass"]

此匹配所有<a> ,無論深度,含有該屬性不等於AClass

至於您的其他問題,關於在xidel的輸出文件中添加換行符,根據您的意思,確實可以使用--output-footer--output-separator標志。

--output-footer將字符串附加到所有輸出的末尾(例如,多個換行符)。

--output-separator在每個項目的末尾附加一個字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM