On Feb 12, 2006, at 11:05 AM, David Vallner wrote:

> Da Nedea 12 Februr 2006 17:18 Zdebel napsal:
>> Helo !
>> I've started to learn ruby and I'm amazed with it. Now I have a  
>> problem
>> that I can't solve. If I have a string like this:
>> "<lyrics artist=XXX album=XXX title=XXX> Lalalalala </lyrics>" how  
>> can I
>> cut the " artist=XXX album=XXX title=XXX" part, so it would look  
>> like:
>> "<lyrcis> Lalalalala </lyrics>" Could you please help me ?
>
> The very geeky, and most probably least error-prone way would be  
> whacking the
> string with a DOM parser, clearing the attributes, and then  
> printing it out
> again. Unfortunately, I haven't been doing any DOM manipulation in  
> Ruby, so I
> can't provide code.

The following is how you do it for valid XML, but the posted example  
wasn't quite:

#!/usr/local/bin/ruby -w

require "rexml/document"

doc = "<lyrics artist='XXX' album='XXX' title='XXX'> Lalalalala </ 
lyrics>"
xml = REXML::Document.new(doc)
xml.root.attributes.clear
xml.write
puts

__END__

James Edward Gray II