Anthony
Anthony

Reputation: 923

removing the xml tags in ruby on rails

I am reading data from an xml doc and placing it on a web page using rails and REMXL. I use

@description1=XPath.match( xmldoc, "////description" )

to get the info into an array and just loop through in my view. However when using

<%= h(@description1[k]) %>

so it looks like

<description>fuzzy slippers</description>

on the web page. Is there a good way of removing the tags? Thanks

Upvotes: 0

Views: 728

Answers (3)

Lars Haugseth
Lars Haugseth

Reputation: 14881

The xpath you are using will return a set of nodes. To get only the content, use:

@description1 = XPath.match(xmldoc, "////description/text()")

Upvotes: 1

Edu
Edu

Reputation: 1969

Did you try

<%= h(@description1[k].text) %>

What does it show?

Upvotes: 1

Gordon Isnor
Gordon Isnor

Reputation: 2105

You might want to look into httparty: http://github.com/jnunemaker/httparty

Upvotes: 1

Related Questions