XML. Prevent < from turning into <
XML. Prevent < from turning into <
am 09.09.2009 11:27:54 von 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 element below:
e1022
Image" width="124" height="70" />]]>
Blue Ski Trousers
8.99
Now, whenever PHP writes this to the XML files, it turns the < and >
into < and > . 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: XML. Prevent < from turning into <
am 09.09.2009 15:26:42 von Phpster
On Wed, Sep 9, 2009 at 5:27 AM, Matthew Croud wrot=
e:
>
> Hiya,
> I'm writing an app that let's my client upload images, the image html cod=
e
> is added to an XML file.
> Take a look at the element below:
>
>
> =A0 =A0e1022
> =A0 =A0
age"
> width=3D"124" height=3D"70" />]]>
> =A0 =A0Blue Ski Trousers
> =A0 =A08.99
> =A0
>
> Now, whenever PHP writes this to the XML files, it turns the < and > into
> < and > . which means it does not display on the webpage. =A0How ca=
n 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?
--=20
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: XML. Prevent < from turning into <
am 09.09.2009 15:33:30 von Matthew Croud
On 9 Sep 2009, at 14:26, Bastien Koert wrote:
> On Wed, Sep 9, 2009 at 5:27 AM, Matthew
> Croud 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 element below:
>>
>>
>> e1022
>>
>> width="124" height="70" />]]>
>> Blue Ski Trousers
>> 8.99
>>
>>
>> Now, whenever PHP writes this to the XML files, it turns the < and
>> > into
>> < and > . 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: XML. Prevent < from turning into <
am 09.09.2009 15:36:42 von Bob McConnell
From: Bastien Koert
> On Wed, Sep 9, 2009 at 5:27 AM, Matthew Croud =
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 element below:
>>
>>
>> =A0 =A0e1022
>> =A0 =A0
alt=3D"Homepage Image"
>> width=3D"124" height=3D"70" />]]>
>> =A0 =A0Blue Ski Trousers
>> =A0 =A08.99
>> =A0
>>
>> Now, whenever PHP writes this to the XML files, it turns the < and > =
into
>> < and > . which means it does not display on the webpage. =
=A0How can I
>> prevent this from happening ?
>>
>=20
> str_replace?
>=20
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: XML. Prevent < from turning into <
am 09.09.2009 15:41:07 von Eddie Drapkin
On Wed, Sep 9, 2009 at 9:33 AM, Matthew Croud wro=
te:
>
> On 9 Sep 2009, at 14:26, Bastien Koert wrote:
>
>> On Wed, Sep 9, 2009 at 5:27 AM, Matthew Croud
>> 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 element below:
>>>
>>>
>>> Â e1022
>>> Â
Image"
>>> width=3D"124" height=3D"70" />]]>
>>> Â Blue Ski Trousers
>>> Â 8.99
>>> Â
>>>
>>> Now, whenever PHP writes this to the XML files, it turns the < and > in=
to
>>> < and > . which means it does not display on the webpage. Â H=
ow 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 soo=
n
> 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: XML. Prevent < from turning into <
am 09.09.2009 15:46:40 von Matthew Croud
--Apple-Mail-11--681105995
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit
On 9 Sep 2009, at 14:36, Bob McConnell wrote:
> From: Bastien Koert
>> On Wed, Sep 9, 2009 at 5:27 AM, Matthew
>> Croud 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 element below:
>>>
>>>
>>> e1022
>>>
>>> Image"
>>> width="124" height="70" />]]>
>>> Blue Ski Trousers
>>> 8.99
>>>
>>>
>>> Now, whenever PHP writes this to the XML files, it turns the < and
>>> > into
>>> < and > . 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:
____________________________________________________________ _____
e1021
Image" width="124" height="70" border="1"
onclick="MM_openBrWindow('uploads/
image1.jpg','Preview','width=680,height=520')" />]]>
Red Jacket
An adult sized red jacket
adult
12.99
e1022
Image" width="124" height="70" border="1"
onclick="MM_openBrWindow('uploads/
image2.jpg','Preview','width=680,height=520')" />]]>
Blue Ski Trousers
A pair of Blue Ski Trousers
child
8.99
____________________________________________________________ ____
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):
e1024
<![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')" />]]>
orange top
an orange jacket
large
14.50
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
--Apple-Mail-11--681105995--
Re: XML. Prevent < from turning into <
am 09.09.2009 16:09:23 von 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
> >> Croud 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 element below:
> >>>
> >>>
> >>> e1022
> >>>
> >>> Image"
> >>> width="124" height="70" />]]>
> >>> Blue Ski Trousers
> >>> 8.99
> >>>
> >>>
> >>> Now, whenever PHP writes this to the XML files, it turns the < and
> >>> > into
> >>> < and > . 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:
> ____________________________________________________________ _____
>
>
>
>
>
> e1021
>
> Image" width="124" height="70" border="1"
> onclick="MM_openBrWindow('uploads/
> image1.jpg','Preview','width=680,height=520')" />]]>
> Red Jacket
> An adult sized red jacket
> adult
> 12.99
>
>
>
> e1022
>
> Image" width="124" height="70" border="1"
> onclick="MM_openBrWindow('uploads/
> image2.jpg','Preview','width=680,height=520')" />]]>
> Blue Ski Trousers
> A pair of Blue Ski Trousers
> child
> 8.99
>
>
>
>
> ____________________________________________________________ ____
>
> 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):
>
>
> e1024
> <![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')" />]]>
> orange top
> an orange jacket
> large
> 14.50
>
>
>
>
>
> 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: XML. Prevent < from turning into <
am 09.09.2009 17:51:52 von 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
>>>>>> Croud 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 element below:
>>>>>>>
>>>>>>>
>>>>>>> e1022
>>>>>>>
>>>>>>> Image"
>>>>>>> width="124" height="70" />]]>
>>>>>>> Blue Ski Trousers
>>>>>>> 8.99
>>>>>>>
>>>>>>>
>>>>>>> Now, whenever PHP writes this to the XML files, it turns the <
>>>>>>> and
>>>>>>>> into
>>>>>>> < and > . 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:
>>>> ____________________________________________________________ _____
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> e1021
>>>>
>>>> Image" width="124" height="70" border="1"
>>>> onclick="MM_openBrWindow('uploads/
>>>> image1.jpg','Preview','width=680,height=520')" />]]>
>>>> Red Jacket
>>>> An adult sized red jacket
>>>> adult
>>>> 12.99
>>>>
>>>>
>>>>
>>>> e1022
>>>>
>>>> Image" width="124" height="70" border="1"
>>>> onclick="MM_openBrWindow('uploads/
>>>> image2.jpg','Preview','width=680,height=520')" />]]>
>>>> Blue Ski Trousers
>>>> A pair of Blue Ski Trousers
>>>> child
>>>> 8.99
>>>>
>>>>
>>>>
>>>>
>>>> ____________________________________________________________ ____
>>>>
>>>> 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):
>>>>
>>>>
>>>> e1024
>>>> <![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')" />]]>
>>>> orange top
>>>> an orange jacket
>>>> large
>>>> 14.50
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 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( "
>> $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 - 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 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 that a text node will have
> the contents automatically made 'safe' for the XML entities which
> are <,
>> , &, etc.
>
> Why are you appending the child item like this? What's wrong with
> adding
> it as a proper object, attributes and all?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
Hi Ash,
Thanks for getting back to me,
In all honesty this method is what's implemented in the course book
i've been following.
I been using XML longer and i've never had this issue using image tags
before and getting the output I expected.
Is there a way around this safety mechanism ? Otherwise i'll have to
think of another way of doing this.
Cheers.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: XML. Prevent < from turning into <
am 09.09.2009 18:04:12 von 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
> >>>>>> Croud 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 element below:
> >>>>>>>
> >>>>>>>
> >>>>>>> e1022
> >>>>>>>
> >>>>>>> Image"
> >>>>>>> width="124" height="70" />]]>
> >>>>>>> Blue Ski Trousers
> >>>>>>> 8.99
> >>>>>>>
> >>>>>>>
> >>>>>>> Now, whenever PHP writes this to the XML files, it turns the <
> >>>>>>> and
> >>>>>>>> into
> >>>>>>> < and > . 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:
> >>>> ____________________________________________________________ _____
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> e1021
> >>>>
> >>>> Image" width="124" height="70" border="1"
> >>>> onclick="MM_openBrWindow('uploads/
> >>>> image1.jpg','Preview','width=680,height=520')" />]]>
> >>>> Red Jacket
> >>>> An adult sized red jacket
> >>>> adult
> >>>> 12.99
> >>>>
> >>>>
> >>>>
> >>>> e1022
> >>>>
> >>>> Image" width="124" height="70" border="1"
> >>>> onclick="MM_openBrWindow('uploads/
> >>>> image2.jpg','Preview','width=680,height=520')" />]]>
> >>>> Blue Ski Trousers
> >>>> A pair of Blue Ski Trousers
> >>>> child
> >>>> 8.99
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> ____________________________________________________________ ____
> >>>>
> >>>> 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):
> >>>>
> >>>>
> >>>> e1024
> >>>> <![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')" />]]>
> >>>> orange top
> >>>> an orange jacket
> >>>> large
> >>>> 14.50
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> 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( "
> >> $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 - 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 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 that a text node will have
> > the contents automatically made 'safe' for the XML entities which
> > are <,
> >> , &, etc.
> >
> > Why are you appending the child item like this? What's wrong with
> > adding
> > it as a proper object, attributes and all?
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>
>
> Hi Ash,
>
> Thanks for getting back to me,
> In all honesty this method is what's implemented in the course book
> i've been following.
>
> I been using XML longer and i've never had this issue using image tags
> before and getting the output I expected.
> Is there a way around this safety mechanism ? Otherwise i'll have to
> think of another way of doing this.
>
> Cheers.
>
Just create the image tag using the same methods as you're creating the
other nodes. So the image object would contain several attribute nodes,
but would have no regular child nodes of its own.
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: XML. Prevent < from turning into <
am 09.09.2009 18:07:21 von 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" wrote in message
news:2C4840C2-45DB-4D6C-B5FA-2CB15B1716A5@obviousdigital.com ...
>
> On 9 Sep 2009, at 14:26, Bastien Koert wrote:
>
>> On Wed, Sep 9, 2009 at 5:27 AM, Matthew Croud
>> 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 element below:
>>>
>>>
>>> e1022
>>>
>>> width="124" height="70" />]]>
>>> Blue Ski Trousers
>>> 8.99
>>>
>>>
>>> Now, whenever PHP writes this to the XML files, it turns the < and
>>> > into
>>> < and > . 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: XML. Prevent < from turning into <
am 09.09.2009 21:03:42 von Ralph Deffke
give it a try with PDATA instead of CDATA and see what happns
"Ashley Sheridan" wrote in message
news:1252512252.2961.40.camel@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
> > >>>>>> Croud 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 element below:
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> e1022
> > >>>>>>>
> > >>>>>>> Image"
> > >>>>>>> width="124" height="70" />]]>
> > >>>>>>> Blue Ski Trousers
> > >>>>>>> 8.99
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> Now, whenever PHP writes this to the XML files, it turns the <
> > >>>>>>> and
> > >>>>>>>> into
> > >>>>>>> < and > . 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:
> > >>>> ____________________________________________________________ _____
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> e1021
> > >>>>
> > >>>> Image" width="124" height="70" border="1"
> > >>>> onclick="MM_openBrWindow('uploads/
> > >>>> image1.jpg','Preview','width=680,height=520')" />]]>
> > >>>> Red Jacket
> > >>>> An adult sized red jacket
> > >>>> adult
> > >>>> 12.99
> > >>>>
> > >>>>
> > >>>>
> > >>>> e1022
> > >>>>
> > >>>> Image" width="124" height="70" border="1"
> > >>>> onclick="MM_openBrWindow('uploads/
> > >>>> image2.jpg','Preview','width=680,height=520')" />]]>
> > >>>> Blue Ski Trousers
> > >>>> A pair of Blue Ski Trousers
> > >>>> child
> > >>>> 8.99
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> ____________________________________________________________ ____
> > >>>>
> > >>>> 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):
> > >>>>
> > >>>>
> > >>>> e1024
> > >>>> <![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')" />]]>
> > >>>> orange top
> > >>>> an orange jacket
> > >>>> large
> > >>>> 14.50
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> 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( "
> > >> $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 - 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 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 that a text node will have
> > > the contents automatically made 'safe' for the XML entities which
> > > are <,
> > >> , &, etc.
> > >
> > > Why are you appending the child item like this? What's wrong with
> > > adding
> > > it as a proper object, attributes and all?
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> > >
> > >
> >
> >
> > Hi Ash,
> >
> > Thanks for getting back to me,
> > In all honesty this method is what's implemented in the course book
> > i've been following.
> >
> > I been using XML longer and i've never had this issue using image tags
> > before and getting the output I expected.
> > Is there a way around this safety mechanism ? Otherwise i'll have to
> > think of another way of doing this.
> >
> > Cheers.
> >
>
> Just create the image tag using the same methods as you're creating the
> other nodes. So the image object would contain several attribute nodes,
> but would have no regular child nodes of its own.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php