Pound symbol (£) in XML

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

User avatar
Jez
Ebase User
Posts: 31
Joined: Thu Aug 21, 2008 11:03 am
Location: Hampshire County Council

Pound symbol (£) in XML

#1

Postby Jez » Tue Apr 14, 2009 1:31 pm

I'm writing some text to an XML file on the ebase server via a custom resource.

It all gets very upset if I try and write a pound (£) symbol to the XML :evil:

From what I've read and been told, this is quite normal and the proper way to do this is to actually replae the £ symbol with the following string (please ignor spaces in the following code!);

Code: Select all

& #163;
The XML then displays the pound symbol when you open it in a browser (or combine it with a friendly Style Sheet). I've tried this by manually hacking the XML and it works just fine (as it does above on this forum if I don't put the space in!!!) :D

The problem I have is that when I try and write the & #163; string to the XML file, something is converting the ampersand to the string & I then end up with the following string in the XML file that's written to the server;

Code: Select all

£
This totally scuppers my attempts to produce the pound symbol as when viewed through a browser it comes out as & #163; and not £ :(

Anyone have any ideas for how I can get round this?

Thanks
0 x
--------------------------------------
Jez Hollinshead - Hampshire CC

AJDulk
Ebase User
Posts: 94
Joined: Fri Sep 14, 2007 12:18 pm
Location: The Netherlands
Contact:

Re: Pound symbol (£) in XML

#2

Postby AJDulk » Tue Apr 14, 2009 4:13 pm

Rather than using #163, use the word pound. The reason is that it degrades better, i.e. if someone is using a browser that does not support the ampersand notation, they still understand the word where they do not understand the number. Funnily enough, this forum does not like the £ notation (at least in preview).

You can do the same for the Euro sign (i.e. €)

Of course, this does not sort your problem out with Ebase encoding the ampersand sign.

Regards,
Antony
0 x

User avatar
Joost
Ebase User
Posts: 49
Joined: Fri Sep 14, 2007 6:14 pm
Location: The Netherlands

Re: Pound symbol (£) in XML

#3

Postby Joost » Mon Apr 20, 2009 8:41 am

Jez wrote:It all gets very upset if I try and write a pound (£) symbol to the XML [...] Anyone have any ideas for how I can get round this?
I suppose you should somehow use CDATA to tell XML or it's parser it should handle the data as-is. I have not tried it with a custom resource though. I currently use it in a velocity script to create XML on the fly and write it to a DB clob.

More info on CDATA at: http://www.w3schools.com/xml/xml_cdata.asp
0 x


Who is online

Users browsing this forum: No registered users and 112 guests