XMLsimple & probem

Hello,

I have problem using XMLsimple.xml_in with ‘&’ character :


&

Illegal character ‘&’ in raw string “&”

The problem is solved when I replace ‘&’ by ‘&amp’

but when I this

#####################################
test = XmlSimple.xml_in(“test.xml”)

test[“visit”].each { |visit|
puts visit[“job”]
}
######################################

that puts me ‘&amp’ and not ‘&’…

To be simple, I juste want to have string with & in my xml file and &
when I puts them after loading.

Thanks for your help.

Matt V. wrote:

The problem is solved when I replace ‘&’ by ‘&amp’

maybe try &
^

Cheers,
Peter


http://www.rubyrailways.com
http://scrubyt.org

Peter S. wrote:

Matt V. wrote:

The problem is solved when I replace ‘&’ by ‘&amp’

maybe try &
^

That’s works fine thanks!
But Why &amp didn’t raised me the same Illegal character error ?
^

On Oct 11, 4:50 am, Matt V. [email protected] wrote:

To be simple, I juste want to have string with & in my xml file and &
when I puts them after loading.

Your xml file must wrap your data in CDATA tags in order for you to
use the raw characters. Change your xml file to look like this:

Enjoy!

Blackie wrote:

On Oct 11, 4:50 am, Matt V. [email protected] wrote:

To be simple, I juste want to have string with & in my xml file and &
when I puts them after loading.

Your xml file must wrap your data in CDATA tags in order for you to
use the raw characters. Change your xml file to look like this:

Enjoy!

You’re a genious, thanks :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs