# XMLsimple & probem

**URL:** <https://www.ruby-forum.com/t/xmlsimple-probem/116929>\
**Category:** Ruby\
**Created:** [October 11, 2007, 10:50am UTC](https://www.ruby-forum.com/t/xmlsimple-probem/116929 "2007-10-11T10:50:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![envex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@envex](https://www.ruby-forum.com/u/envex)\
**Post date:** [October 11, 2007, 10:50am UTC](https://www.ruby-forum.com/t/xmlsimple-probem/116929/1 "2007-10-11T10:50:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![envex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@envex](https://www.ruby-forum.com/u/envex)\
**Post date:** [October 11, 2007, 1:49pm UTC](https://www.ruby-forum.com/t/xmlsimple-probem/116929/2 "2007-10-11T13:49:26Z")

</div>

Matt V. wrote:

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

maybe try &  
^

Cheers,  
Peter

* * *

[http://www.rubyrailways.com](http://www.rubyrailways.com)  
[http://scrubyt.org](http://scrubyt.org)

---

<div class="post-metadata">

**Author:** ![envex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@envex](https://www.ruby-forum.com/u/envex)\
**Post date:** [October 11, 2007, 2:36pm UTC](https://www.ruby-forum.com/t/xmlsimple-probem/116929/3 "2007-10-11T14:36:57Z")

</div>

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 ?  
^

---

<div class="post-metadata">

**Author:** ![envex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@envex](https://www.ruby-forum.com/u/envex)\
**Post date:** [October 11, 2007, 2:45pm UTC](https://www.ruby-forum.com/t/xmlsimple-probem/116929/4 "2007-10-11T14:45:49Z")

</div>

On Oct 11, 4:50 am, Matt V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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!

---

<div class="post-metadata">

**Author:** ![envex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbe5ce/32.png) [@envex](https://www.ruby-forum.com/u/envex)\
**Post date:** [October 11, 2007, 2:55pm UTC](https://www.ruby-forum.com/t/xmlsimple-probem/116929/5 "2007-10-11T14:55:25Z")

</div>

Blackie wrote:

> On Oct 11, 4:50 am, Matt V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 🙂
