D
D
Dg_Mg2017-08-14 08:57:07
ruby
Dg_Mg, 2017-08-14 08:57:07

Removing child elements in xpath query?

<div class="name-class">
   <h1>
        <span> 
                <a href="#">ваше</a>
        </span>
        Имя
   </h1>  
</div>

If I make a request
(doc / "//div[@class='name-class']/h1").each do |row|
product_name = row.text.strip

then "your name" is displayed. Tell me how to delete everything inside ? <span>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dg_Mg, 2017-08-14
@Dg_Mg

Understood. The line removes everything. (doc / 'span').remove

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question