[英]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.