Welcome to WebmasterWorld Guest from 54.161.187.250

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP/XML Issue that Is Driving Me Nuts

   
9:09 pm on Jan 1, 2010 (gmt 0)

10+ Year Member



Hey Everyone

I am trying to dynamically create a block of XML text to use in a program that I recently purchased. This works totally fine:

$strXML .= "<chart caption='" . $state1 . " Unemployment Rate' subCaption='For " . $year . " - Test' xAxisName='Month' yAxisName='Unemployment Rate' showBorder='0' showValues='0'>";

However, when I change it to this:

$strXML .= "<chart caption='" . $state1 . " Unemployment Rate' subCaption='For " . $year . " - Test' xAxisName='Month' yAxisName='Unemployment Rate' showBorder='0' showValues='0' numberSuffix='%'>";

I get an Invalid XML Data message.

I know what the problem is - the % is causing issues.

However, I am not sure how to fix it! I have tried changing it to the HTML code, etc. , but nothing seems to work.

Can anyone help? Thanks!

9:48 pm on Jan 1, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Not sure if this will help, but XML is extremely strict. Did you try an entity?

....numberSuffix='&#37;'>";

or it may need to be encoded.

10:54 pm on Jan 1, 2010 (gmt 0)

10+ Year Member



Awesome rocknbil - thank you. It worked when I encoded it - thanks!