Home > Software engineering >  Need help on selecting Nodes using nokogiri XPath
Need help on selecting Nodes using nokogiri XPath

Time:02-10

so my html is file is:

<img src="/icons/folder.gif" alt="[DIR]"> <a href="convobot-main/">convobot-main/</a>                    2022-01-27 13:55    -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="matlab/">matlab/</a>                           2022-01-31 11:58    -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test/">test/</a>                             2022-01-27 13:52    -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test3 - Copy/">test3 - Copy/</a>                     2022-02-09 15:09    -
<img src="/icons/folder.gif" alt="[DIR]"> <a href="test3/">test3/</a>                            2022-02-09 10:47    -
<img src="/icons/unknown.gif" alt="[   ]"> <a href="Quadractic.mlx">Quadractic.mlx</a>                    2022-01-21 15:02  3.3K

and I'm trying to slect matlab, test,test3-copy, test3. I tried doing html_doc.xpath('//img[@alt="[DIR]"]/../a/@href') but thats returning every thing after href even if alt isnt [DIR]. How can I fix this?

CodePudding user response:

  •  Tags:  
  • Related