Find tag with id including [] with Nokogiri

后端 未结 3 1080
时光说笑
时光说笑 2021-02-14 05:09

I have an html element like:

I want to search for this element by id, but it seems that nokogiri is getting confus

3条回答
  •  被撕碎了的回忆
    2021-02-14 05:38

    you can also do it this way

    el = doc.xpath("id(spam[500])").first
    

    for elements having id's you can call them directly through id because its always unique.

    for finding out xpaths, please add a 'xpath checker' plugin to firefox. It helps a lot and very easy

提交回复
热议问题