Search code examples
ruby-on-railsrubyrexml

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


Solution

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

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