# Removing a tag from an xml document

**URL:** <https://www.ruby-forum.com/t/removing-a-tag-from-an-xml-document/77113>\
**Category:** Ruby\
**Created:** [November 24, 2006, 11:42am UTC](https://www.ruby-forum.com/t/removing-a-tag-from-an-xml-document/77113 "2006-11-24T11:42:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [November 24, 2006, 11:42am UTC](https://www.ruby-forum.com/t/removing-a-tag-from-an-xml-document/77113/1 "2006-11-24T11:42:28Z")

</div>

Hi,

Im trying to convert part of a HTML document to REXML and its throwing  
it back at me due to the fact that the html document isnt valid XML due  
to one closing tag which doesnt have an opener.

heres the xml:

```
        <td></td>

      </tr>
    </thead>

      <tbody>

        <tr class="odd-row ">
          <td class="data"><a 

```

href=“buildresults/henry-mobile-server”\>henry-  
mobile-server

  
  
  

```
          <td class="data"><input id="force_henry-mobile-server" 

```

type=“butto  
n”  
onclick=“callServer(‘[http://etab-va:8000/i](http://etab-va:8000/i)  
nvoke?operation=build&objectname=CruiseControl+Project%3Aname%3Dhenry-mobile-ser  
ver’, ‘henry-mobile-server’)”  
value=“Build”/\>

```
        </tr>

      </tbody>

        <tr class="even-row ">
          <td class="data"><a 

```

href=“buildresults/henry-mobile-server-nightly  
-build”\>henry-mobile-server-nightly-build

  
  
  

```
          <td class="data"><input 

```

id=“force\_henry-mobile-server-nightly-buil  
d” type=“button”  
onclick=“callServer(‘[http://etab-va:8000/i](http://etab-va:8000/i)  
nvoke?operation=build&objectname=CruiseControl+Project%3Aname%3Dhenry-mobile-ser  
ver-nightly-build’, ‘henry-mobile-server-nightly-build’)”  
value=“Build”/\>

```
        </tr>

      </tbody>
      </table>

```

What i need to do is to strip out the final “” tag from the  
file.

The html is being fethced using net/http and then that part of the page  
is being extracted from the full page with the following line:

gathered\_data = response.body[table\_start\_pos,height]

any ideas on how I should remove that tag?

Cheers,

Chris

| [Project](https://www.ruby-forum.com/index.jsp?sort=project) | [Status _(sinc e)_](https://www.ruby-forum.com/index.jsp?sort=status) | [Last failu re](https://www.ruby-forum.com/index.jsp?sort=last%20%20failure) | [Last su ccessful](https://www.ruby-forum.com/index.jsp?sort=last%20%20successful) | Label | ? _(10:05)_ | | 09:31 | build.19 | ? _(10:05)_ | | | |

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [November 24, 2006, 1:37pm UTC](https://www.ruby-forum.com/t/removing-a-tag-from-an-xml-document/77113/2 "2006-11-24T13:37:45Z")

</div>

Hello,

> What i need to do is to strip out the final “” tag from the  
> file.

just do this:

input.sub(‘’) {‘’}

Cheers,  
Peter

\_\_  
[http://www.rubyrailways.com](http://www.rubyrailways.com)

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [November 24, 2006, 1:43pm UTC](https://www.ruby-forum.com/t/removing-a-tag-from-an-xml-document/77113/3 "2006-11-24T13:43:32Z")

</div>

Hi Peter,

Thanks for the reply.

I ended up using gsub as I had a number of those records present but its  
pretty much the same.

Cheers,

Chris
