简体   繁体   English

如何从Xidel输出中排除类

[英]How to exclude class from Xidel output

I want to refine my Xidel output using the xpath: //BODY/DIV by removing the lines containing "AClass", and keep the lines with "MyClass" only 我想使用xpath优化我的Xidel输出: // BODY / DIV,方法是删除包含“ AClass”的行,并仅保留带有“ MyClass”的行

Can I add line break to Xidel output file? 我可以在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>

To exclude an attribute with XQuery we can use regular inequation, in your example it would be //a[@class !="AClass"] . 要使用XQuery排除属性,我们可以使用常规的不等式,在您的示例中,它是//a[@class !="AClass"]

This matches all <a> , regardless of depth, containing the attribute class which isn't equal to AClass . 此匹配所有<a> ,无论深度,含有该属性不等于AClass

As for your other question, about adding line breaks to xidel's output file, it is indeed possible with either --output-footer or --output-separator flags depending on what you mean. 至于您的其他问题,关于在xidel的输出文件中添加换行符,根据您的意思,确实可以使用--output-footer--output-separator标志。

--output-footer appends a string to the end of all output (for instance a multiple line breaks). --output-footer将字符串附加到所有输出的末尾(例如,多个换行符)。

--output-separator appends a string to the end each item. --output-separator在每个项目的末尾附加一个字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM