Normalizing XML tag values

  • Thread starter Alexey Verkhovsky
  • Start date
A

Alexey Verkhovsky

Hi all,

I am looking for some piece of Ruby code that normalizes XML attribute
values (i.e., replaces '<' with '&@60;', etc).

I need it for this project: http://rubyforge.org/projects/test-report/,
and I am sure that somebody has already invented this particular bicycle
in Ruby.

Best regards,
Alex
 
S

Sam Stephenson

I am looking for some piece of Ruby code that normalizes XML attribute
values (i.e., replaces '<' with '&@60;', etc).

I'm not sure what &@60; is. Is this what you mean?

| irb(main):001:0> require 'rexml/text'
| => true
Best regards,
Alex

Sam
 
A

Alexey Verkhovsky

I'm not sure what &@60; is. Is this what you mean? [snip]
| irb(main):002:0> REXML::Text.normalize '<foo & bar>'
| => "&lt;foo &amp; bar&gt;"

Yes, that's it. Thanks!

I mistakenly thought that rexml was only for parsing XML. Now I know
that it's also for writing :)

Best regards,
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top