Re: XML. Prevent < from turning into <
| From: | Matthew Croud | Date: | Wed, 09 Sep 2009 13:46:40 +0000 |
| Subject: | Re: XML. Prevent < from turning into < | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297817@lists.php.net to get a copy of this message | ||
On 9 Sep 2009, at 14:36, Bob McConnell wrote:
From: Bastien KoertHi Bob, Nope the string doesn't get passed into any function. Here is the XML: _________________________________________________________________ <?xml version="1.0" encoding="UTF-8"?> <clothes> <item Code="e1021">On Wed, Sep 9, 2009 at 5:27 AM, Matthew Croud<matt@obviousdigital.com> wrote:intoHiya, I'm writing an app that let's my client upload images, the image html code is added to an XML file. Take a look at the <image> element below: <item Code="e1022"> <code>e1022</code> <image><![CDATA[<img src="uploads/image2.jpg" alt="Homepage Image" width="124" height="70" />]]></image> <name>Blue Ski Trousers</name> <price>8.99</price> </item> Now, whenever PHP writes this to the XML files, it turns the < andDoes the xml string get passed to htmlentities() or a similar function before it is sent to the browser? That would explain the substitutions. I saw an xmlentities() variation mentioned somewhere. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php< and > . which means it does not display on the webpage. How can I prevent this from happening ?str_replace?
<code>e1021</code>
<image><![CDATA[<img src="uploads/image1.jpg" alt="Homepage Image" width="124" height="70" border="1" onclick="MM_openBrWindow('uploads/image1.jpg','Preview','width=680,height=520')" />]]></image>
<name>Red Jacket</name>
<desc>An adult sized red jacket</desc>
<size>adult</size>
<price>12.99</price>
</item>
<item Code="e1022">
<code>e1022</code>
<image><![CDATA[<img src="uploads/image2.jpg" alt="Homepage Image" width="124" height="70" border="1" onclick="MM_openBrWindow('uploads/image2.jpg','Preview','width=680,height=520')" />]]></image>
<name>Blue Ski Trousers</name>
<desc>A pair of Blue Ski Trousers</desc>
<size>child</size>
<price>8.99</price>
</item>
</clothes>
________________________________________________________________
Now the image tags I have written here I have done manually, but when I use PHP using DOM they come out like this (note the image element):
<item Code="e1024">
<code>e1024</code>
<image><![CDATA[<img src="uploads/image4.jpg" alt="Homepage Image" width="124" height="70" border="1" onclick="MM_openBrWindow('uploads/image4.jpg','Preview','width=680,height=520')" />]]></image>
<name>orange top</name>
<desc>an orange jacket</desc>
<size>large</size>
<price>14.50</price>
</item>
Matthew Croud
Studio
Obvious Print Solutions Limited
Unit 3 Abbeygate Court
Stockett Lane
Maidstone
Kent
ME15 0PP
T | 0845 094 9704
F | 0845 094 9705
www.obviousprint.com