简体   繁体   中英

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

Can I add line break to Xidel output file?

<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"] .

This matches all <a> , regardless of depth, containing the attribute class which isn't equal to 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.

--output-footer appends a string to the end of all output (for instance a multiple line breaks).

--output-separator appends a string to the end each item.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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