# Removing the inner elements

**URL:** <https://www.ruby-forum.com/t/removing-the-inner-elements/175387>\
**Category:** Rails\
**Created:** [September 12, 2009, 1:40pm UTC](https://www.ruby-forum.com/t/removing-the-inner-elements/175387 "2009-09-12T13:40:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashanth\_hiremath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/df705f/32.png) [@prashanth\_hiremath](https://www.ruby-forum.com/u/prashanth_hiremath)\
**Post date:** [September 12, 2009, 1:40pm UTC](https://www.ruby-forum.com/t/removing-the-inner-elements/175387/1 "2009-09-12T13:40:57Z")

</div>

Hi

```
  M getting some problems in remove the span tags

```

i have First Second Third

i wanna remove first and second span tags how can i achieve it help me

OUTPUT:

Third

I have an hpricot syntax so that i can remove all the span tags i unable  
to  
remove it

Regards  
Prashanth

---

<div class="post-metadata">

**Author:** ![prashanth\_hiremath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/df705f/32.png) [@prashanth\_hiremath](https://www.ruby-forum.com/u/prashanth_hiremath)\
**Post date:** [September 12, 2009, 5:54pm UTC](https://www.ruby-forum.com/t/removing-the-inner-elements/175387/2 "2009-09-12T17:54:56Z")

</div>

On Sat, Sep 12, 2009 at 4:39 AM, prashanth hiremath  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i have First Second Third

FYI, that sample is bad XML – second span isn’t closed.

> i wanna remove first and second span tags how can i achieve it help me
> 
> OUTPUT:
> 
> Third

I would probably use Nokogiri for this rather than Hpricot, but post  
the code you’re having problems with.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan
