[PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Matthew Croud


Hiya,
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
codee1022/code
image![CDATA[img src=uploads/image2.jpg alt=Homepage  
Image width=124 height=70 /]]/image

nameBlue Ski Trousers/name
price8.99/price
  /item

Now, whenever PHP writes this to the XML files, it turns the  and   
into lt; and gt; . which means it does not display on the webpage.   
How can I prevent this from happening ?


Many thanks,
Matt


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Bastien Koert
On Wed, Sep 9, 2009 at 5:27 AM, Matthew Croudm...@obviousdigital.com wrote:

 Hiya,
 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
    codee1022/code
    image![CDATA[img src=uploads/image2.jpg alt=Homepage Image
 width=124 height=70 /]]/image
    nameBlue Ski Trousers/name
    price8.99/price
  /item

 Now, whenever PHP writes this to the XML files, it turns the  and  into
 lt; and gt; . which means it does not display on the webpage.  How can I
 prevent this from happening ?

 Many thanks,
 Matt


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



str_replace?


-- 

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Bob McConnell
From: Bastien Koert
 On Wed, Sep 9, 2009 at 5:27 AM, Matthew Croudm...@obviousdigital.com wrote:

 Hiya,
 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
    codee1022/code
    image![CDATA[img src=uploads/image2.jpg alt=Homepage Image
 width=124 height=70 /]]/image
    nameBlue Ski Trousers/name
    price8.99/price
  /item

 Now, whenever PHP writes this to the XML files, it turns the  and  into
 lt; and gt; . which means it does not display on the webpage.  How can I
 prevent this from happening ?

 
 str_replace?
 

Does 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



Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Matthew Croud


On 9 Sep 2009, at 14:26, Bastien Koert wrote:

On Wed, Sep 9, 2009 at 5:27 AM, Matthew  
Croudm...@obviousdigital.com wrote:


Hiya,
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
   codee1022/code
   image![CDATA[img src=uploads/image2.jpg alt=Homepage Image
width=124 height=70 /]]/image
   nameBlue Ski Trousers/name
   price8.99/price
 /item

Now, whenever PHP writes this to the XML files, it turns the  and  
 into
lt; and gt; . which means it does not display on the webpage.   
How can I

prevent this from happening ?

Many thanks,
Matt


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




str_replace?


--

Bastien

Cat, the other other white meat



I've tried that but no matter what i do in the PHP side of things, as  
soon as I save that XML the conversion takes place.
Should the XML be encoded in any way, is there a setting somewhere  
that prevents this ?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Eddie Drapkin
On Wed, Sep 9, 2009 at 9:33 AM, Matthew Croud m...@obviousdigital.com wrote:

 On 9 Sep 2009, at 14:26, Bastien Koert wrote:

 On Wed, Sep 9, 2009 at 5:27 AM, Matthew Croudm...@obviousdigital.com
 wrote:

 Hiya,
 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
   codee1022/code
   image![CDATA[img src=uploads/image2.jpg alt=Homepage Image
 width=124 height=70 /]]/image
   nameBlue Ski Trousers/name
   price8.99/price
  /item

 Now, whenever PHP writes this to the XML files, it turns the  and  into
 lt; and gt; . which means it does not display on the webpage.  How can
 I
 prevent this from happening ?

 Many thanks,
 Matt


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 str_replace?


 --

 Bastien

 Cat, the other other white meat


 I've tried that but no matter what i do in the PHP side of things, as soon
 as I save that XML the conversion takes place.
 Should the XML be encoded in any way, is there a setting somewhere that
 prevents this ?

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Perhaps you'd be so kind as to share with us what code you're using to
generate the erroneous XML?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Matthew Croud


On 9 Sep 2009, at 14:36, Bob McConnell wrote:


From: Bastien Koert
On Wed, Sep 9, 2009 at 5:27 AM, Matthew  
Croudm...@obviousdigital.com wrote:


Hiya,
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
   codee1022/code
   image![CDATA[img src=uploads/image2.jpg alt=Homepage  
Image

width=124 height=70 /]]/image
   nameBlue Ski Trousers/name
   price8.99/price
 /item

Now, whenever PHP writes this to the XML files, it turns the  and  
 into
lt; and gt; . which means it does not display on the webpage.   
How can I

prevent this from happening ?



str_replace?



Does 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




Hi 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
codee1021/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

nameRed Jacket/name
descAn adult sized red jacket/desc
sizeadult/size
price12.99/price
  /item

  item Code=e1022
codee1022/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

nameBlue Ski Trousers/name
descA pair of Blue Ski Trousers/desc
sizechild/size
price8.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
codee1024/code
imagelt;![CDATA[lt;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') /gt;]]gt;/image

nameorange top/name
descan orange jacket/desc
sizelarge/size
price14.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







Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Ashley Sheridan
On Wed, 2009-09-09 at 14:46 +0100, Matthew Croud wrote:
 On 9 Sep 2009, at 14:36, Bob McConnell wrote:
 
  From: Bastien Koert
  On Wed, Sep 9, 2009 at 5:27 AM, Matthew  
  Croudm...@obviousdigital.com wrote:
 
  Hiya,
  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
 codee1022/code
 image![CDATA[img src=uploads/image2.jpg alt=Homepage  
  Image
  width=124 height=70 /]]/image
 nameBlue Ski Trousers/name
 price8.99/price
   /item
 
  Now, whenever PHP writes this to the XML files, it turns the  and  
   into
  lt; and gt; . which means it does not display on the webpage.   
  How can I
  prevent this from happening ?
 
 
  str_replace?
 
 
  Does 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
 
 
 
 Hi 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
  codee1021/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
  nameRed Jacket/name
  descAn adult sized red jacket/desc
  sizeadult/size
  price12.99/price
/item
 
item Code=e1022
  codee1022/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
  nameBlue Ski Trousers/name
  descA pair of Blue Ski Trousers/desc
  sizechild/size
  price8.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
 codee1024/code
 imagelt;![CDATA[lt;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') /gt;]]gt;/image
 nameorange top/name
 descan orange jacket/desc
 sizelarge/size
 price14.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
 
 
 
 
 
I've not experienced this with using any DOM functions, but if we can
see your code it might help us.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Matthew Croud


On 9 Sep 2009, at 16:37, Ashley Sheridan wrote:


On Wed, 2009-09-09 at 15:14 +0100, Matthew Croud wrote:

On 9 Sep 2009, at 15:09, Ashley Sheridan wrote:


On Wed, 2009-09-09 at 14:46 +0100, Matthew Croud wrote:

On 9 Sep 2009, at 14:36, Bob McConnell wrote:


From: Bastien Koert

On Wed, Sep 9, 2009 at 5:27 AM, Matthew
Croudm...@obviousdigital.com wrote:


Hiya,
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
 codee1022/code
 image![CDATA[img src=uploads/image2.jpg alt=Homepage
Image
width=124 height=70 /]]/image
 nameBlue Ski Trousers/name
 price8.99/price
/item

Now, whenever PHP writes this to the XML files, it turns the   
and

into

lt; and gt; . which means it does not display on the webpage.
How can I
prevent this from happening ?



str_replace?



Does 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




Hi 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
   codee1021/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
   nameRed Jacket/name
   descAn adult sized red jacket/desc
   sizeadult/size
   price12.99/price
 /item

 item Code=e1022
   codee1022/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
   nameBlue Ski Trousers/name
   descA pair of Blue Ski Trousers/desc
   sizechild/size
   price8.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
codee1024/code
imagelt;![CDATA[lt;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') /gt;]]gt;/image
nameorange top/name
descan orange jacket/desc
sizelarge/size
price14.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





I've not experienced this with using any DOM functions, but if we  
can

see your code it might help us.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--  
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php






Well i'll pop the PHP down here, i'll trim it as much as i can:


$code = $_POST['code'];
$name = $_POST['name'];
$desc = $_POST['desc'];
$size = $_POST['size'];
$price = $_POST['price'];


#load an XML document into the DOM

$dom = new DomDocument();
$dom - load(items.xml);

#create elements

$Xitem =  $dom - createElement(item);
$Xcode =  $dom - createElement(code);
$Ximage =  $dom - createElement(image);
$Xname =  $dom - createElement(name);
$Xdesc = $dom - createElement(desc);
$Xsize = $dom - createElement(size);
$Xprice = $dom - createElement(price);

#create text nodes

$Xcodetext =  $dom - createTextNode($code);
$Ximagetext =  $dom - createTextNode( ![CDATA[img src=\uploads/
$UploadName\ alt=\Homepage Image\ width=\124\ height=\70\
border=\1\ onclick=\MM_openBrWindow('uploads/
$UploadName','Preview','width=680,height=520')\ /]] );
$Xnametext =  $dom - createTextNode($name);
$Xdesctext = $dom - createTextNode($desc);
$Xsizetext =$dom - createTextNode($size);
$Xpricetext =$dom - createTextNode($price);

#append the text nodes to the inner nested elements

$Xcode  - appendChild($Xcodetext);
$Ximage  - appendChild($Ximagetext);
$Xname  - appendChild($Xnametext);
$Xdesc - appendChild($Xdesctext);
$Xsize- appendChild($Xsizetext);
$Xprice- appendChild($Xpricetext);

#append the inner nested elements to the item element

$Xitem - appendChild($Xcode);
$Xitem - appendChild($Ximage);
$Xitem - appendChild($Xname);
$Xitem - appendChild($Xdesc);
$Xitem - appendChild($Xsize);
$Xitem - appendChild($Xprice);
$Xitem - setAttribute(Code,$code);

#append the title element to the root element

$dom - documentElement - appendChild($Xitem);

#create a new enlarged xml document

$dom - save(items.xml);

_
It looks like it's because you are creating an image object by  
appending

a text node inside CDATA to it. My guess is 

Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Ashley Sheridan
On Wed, 2009-09-09 at 16:51 +0100, Matthew Croud wrote:
 On 9 Sep 2009, at 16:37, Ashley Sheridan wrote:
 
  On Wed, 2009-09-09 at 15:14 +0100, Matthew Croud wrote:
  On 9 Sep 2009, at 15:09, Ashley Sheridan wrote:
 
  On Wed, 2009-09-09 at 14:46 +0100, Matthew Croud wrote:
  On 9 Sep 2009, at 14:36, Bob McConnell wrote:
 
  From: Bastien Koert
  On Wed, Sep 9, 2009 at 5:27 AM, Matthew
  Croudm...@obviousdigital.com wrote:
 
  Hiya,
  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
   codee1022/code
   image![CDATA[img src=uploads/image2.jpg alt=Homepage
  Image
  width=124 height=70 /]]/image
   nameBlue Ski Trousers/name
   price8.99/price
  /item
 
  Now, whenever PHP writes this to the XML files, it turns the   
  and
  into
  lt; and gt; . which means it does not display on the webpage.
  How can I
  prevent this from happening ?
 
 
  str_replace?
 
 
  Does 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
 
 
 
  Hi 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
 codee1021/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
 nameRed Jacket/name
 descAn adult sized red jacket/desc
 sizeadult/size
 price12.99/price
   /item
 
   item Code=e1022
 codee1022/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
 nameBlue Ski Trousers/name
 descA pair of Blue Ski Trousers/desc
 sizechild/size
 price8.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
  codee1024/code
  imagelt;![CDATA[lt;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') /gt;]]gt;/image
  nameorange top/name
  descan orange jacket/desc
  sizelarge/size
  price14.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
 
 
 
 
 
  I've not experienced this with using any DOM functions, but if we  
  can
  see your code it might help us.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 
  --  
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
  Well i'll pop the PHP down here, i'll trim it as much as i can:
  
 
  $code = $_POST['code'];
  $name = $_POST['name'];
  $desc = $_POST['desc'];
  $size = $_POST['size'];
  $price = $_POST['price'];
 
 
  #load an XML document into the DOM
 
  $dom = new DomDocument();
  $dom - load(items.xml);
 
  #create elements
 
  $Xitem =  $dom - createElement(item);
  $Xcode =  $dom - createElement(code);
  $Ximage =  $dom - createElement(image);
  $Xname =  $dom - createElement(name);
  $Xdesc = $dom - createElement(desc);
  $Xsize = $dom - createElement(size);
  $Xprice = $dom - createElement(price);
 
  #create text nodes
 
  $Xcodetext =  $dom - createTextNode($code);
  $Ximagetext =  $dom - createTextNode( ![CDATA[img src=\uploads/
  $UploadName\ alt=\Homepage Image\ width=\124\ height=\70\
  border=\1\ onclick=\MM_openBrWindow('uploads/
  $UploadName','Preview','width=680,height=520')\ /]] );
  $Xnametext =  $dom - createTextNode($name);
  $Xdesctext = $dom - createTextNode($desc);
  $Xsizetext =$dom - createTextNode($size);
  $Xpricetext =$dom - createTextNode($price);
 
  #append the text nodes to the inner nested elements
 
  $Xcode  - appendChild($Xcodetext);
  $Ximage  - appendChild($Ximagetext);
  $Xname  - appendChild($Xnametext);
  $Xdesc - appendChild($Xdesctext);
  $Xsize- appendChild($Xsizetext);
  $Xprice- appendChild($Xpricetext);
 
  #append the inner nested elements to the item element
 
  $Xitem - appendChild($Xcode);
  $Xitem - appendChild($Ximage);
  $Xitem - appendChild($Xname);
  $Xitem - appendChild($Xdesc);
  $Xitem - appendChild($Xsize);
  $Xitem - 

Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Tony Marston
You need to look at disable_output_escaping at 
http://www.w3.org/TR/xslt#disable-output-escaping

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

Matthew Croud m...@obviousdigital.com wrote in message 
news:2c4840c2-45db-4d6c-b5fa-2cb15b171...@obviousdigital.com...

 On 9 Sep 2009, at 14:26, Bastien Koert wrote:

 On Wed, Sep 9, 2009 at 5:27 AM, Matthew  Croudm...@obviousdigital.com 
 wrote:

 Hiya,
 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
codee1022/code
image![CDATA[img src=uploads/image2.jpg alt=Homepage Image
 width=124 height=70 /]]/image
nameBlue Ski Trousers/name
price8.99/price
  /item

 Now, whenever PHP writes this to the XML files, it turns the  and
  into
 lt; and gt; . which means it does not display on the webpage.   How 
 can I
 prevent this from happening ?

 Many thanks,
 Matt


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 str_replace?


 -- 

 Bastien

 Cat, the other other white meat


 I've tried that but no matter what i do in the PHP side of things, as 
 soon as I save that XML the conversion takes place.
 Should the XML be encoded in any way, is there a setting somewhere  that 
 prevents this ? 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Ralph Deffke
give it a try with PDATA instead of CDATA and see what happns


Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
news:1252512252.2961.40.ca...@localhost...
 On Wed, 2009-09-09 at 16:51 +0100, Matthew Croud wrote:
  On 9 Sep 2009, at 16:37, Ashley Sheridan wrote:
 
   On Wed, 2009-09-09 at 15:14 +0100, Matthew Croud wrote:
   On 9 Sep 2009, at 15:09, Ashley Sheridan wrote:
  
   On Wed, 2009-09-09 at 14:46 +0100, Matthew Croud wrote:
   On 9 Sep 2009, at 14:36, Bob McConnell wrote:
  
   From: Bastien Koert
   On Wed, Sep 9, 2009 at 5:27 AM, Matthew
   Croudm...@obviousdigital.com wrote:
  
   Hiya,
   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
codee1022/code
image![CDATA[img src=uploads/image2.jpg alt=Homepage
   Image
   width=124 height=70 /]]/image
nameBlue Ski Trousers/name
price8.99/price
   /item
  
   Now, whenever PHP writes this to the XML files, it turns the 
   and
   into
   lt; and gt; . which means it does not display on the webpage.
   How can I
   prevent this from happening ?
  
  
   str_replace?
  
  
   Does 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
  
  
  
   Hi 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
  codee1021/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
  nameRed Jacket/name
  descAn adult sized red jacket/desc
  sizeadult/size
  price12.99/price
/item
  
item Code=e1022
  codee1022/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
  nameBlue Ski Trousers/name
  descA pair of Blue Ski Trousers/desc
  sizechild/size
  price8.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
   codee1024/code
   imagelt;![CDATA[lt;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') /gt;]]gt;/image
   nameorange top/name
   descan orange jacket/desc
   sizelarge/size
   price14.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
  
  
  
  
  
   I've not experienced this with using any DOM functions, but if we
   can
   see your code it might help us.
  
   Thanks,
   Ash
   http://www.ashleysheridan.co.uk
  
  
  
  
   -- 
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
  
  
   Well i'll pop the PHP down here, i'll trim it as much as i can:
  

  
   $code = $_POST['code'];
   $name = $_POST['name'];
   $desc = $_POST['desc'];
   $size = $_POST['size'];
   $price = $_POST['price'];
  
  
   #load an XML document into the DOM
  
   $dom = new DomDocument();
   $dom - load(items.xml);
  
   #create elements
  
   $Xitem =  $dom - createElement(item);
   $Xcode =  $dom - createElement(code);
   $Ximage =  $dom - createElement(image);
   $Xname =  $dom - createElement(name);
   $Xdesc = $dom - createElement(desc);
   $Xsize = $dom - createElement(size);
   $Xprice = $dom - createElement(price);
  
   #create text nodes
  
   $Xcodetext =  $dom - createTextNode($code);
   $Ximagetext =  $dom - createTextNode( ![CDATA[img src=\uploads/
   $UploadName\ alt=\Homepage Image\ width=\124\ height=\70\
   border=\1\ onclick=\MM_openBrWindow('uploads/
   $UploadName','Preview','width=680,height=520')\ /]] );
   $Xnametext =  $dom - createTextNode($name);
   $Xdesctext = $dom - createTextNode($desc);
   $Xsizetext =$dom - createTextNode($size);
   $Xpricetext =$dom - createTextNode($price);
  
   #append the text nodes to the inner nested elements
  
   $Xcode  - appendChild($Xcodetext);
   $Ximage  - appendChild($Ximagetext);
   $Xname  - appendChild($Xnametext);
   $Xdesc -