2016-04-28 46 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'會返回'div'列表,而不是'a's。通常可以用'[]'或者'except'完成過濾 – BeniBela

回答

0

要排除使用XQuery,我們可以使用常規的不等式的屬性,在你的榜樣將是//a[@class !="AClass"]

這匹配所有<a>,無論深度如何,都包含屬性類,其中不等於AClass

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

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

--output-separator將一個字符串追加到每個項目的末尾。