[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

XMLsimple & probem

Matt Valblade

10/11/2007 8:50:00 AM

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.
--
Posted via http://www.ruby-....

4 Answers

Peter Szinek

10/11/2007 11:49:00 AM

0

Matt Valblade wrote:
> 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'

maybe try &amp;
^

Cheers,
Peter
___
http://www.rubyra...
http://s...


Matt Valblade

10/11/2007 12:37:00 PM

0

Peter Szinek wrote:
> Matt Valblade wrote:
>>
>> The problem is solved when I replace '&' by '&amp'
>
> maybe try &amp;
> ^

That's works fine thanks!
But Why &amp didn't raised me the same Illegal character error ?
^
--
Posted via http://www.ruby-....

Blackie

10/11/2007 12:41:00 PM

0

On Oct 11, 4:50 am, Matt Valblade <valbl...@gmail.com> 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:

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

Enjoy!



Matt Valblade

10/11/2007 12:55:00 PM

0

Blackie wrote:
> On Oct 11, 4:50 am, Matt Valblade <valbl...@gmail.com> 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:
>
> <test>
> <visit>
> <job><![CDATA[Pork & Beans]]></job>
> </visit>
> </test>
>
> Enjoy!

You're a genious, thanks :)
--
Posted via http://www.ruby-....