XMLsimple & probem

M

Matt Valblade

Hello,

I have problem using XMLsimple.xml_in with '&' character :
<test>
<visit>
<job>&</job>
</visit>
</test>

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.
 
B

Blackie

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:

<test>
<visit>
<job><![CDATA[Pork & Beans]]></job>
</visit>
</test>

Enjoy!
 
M

Matt Valblade

Blackie said:
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:

<test>
<visit>
<job><![CDATA[Pork & Beans]]></job>
</visit>
</test>

Enjoy!

You're a genious, thanks :)
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top