2016-04-28 47 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将一个字符串追加到每个项目的末尾。