[PHP] DOM loadXML not loading doctype as expected in PHP5

2004-08-30 Thread David Numan
Hi

I'm working on a project using PHP5 and I'm using the DOM extension
quite heavily. I need to be able to store various character entities
such as $nbsp; and é Note: this is for a custom XML document, not
standard (X)HTML.

When I load my XML string into my domDocument I've been trying
variations of $doctype1 and $doctype2 below. Here is my code:

$doctype1 = <<http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent";>
%ISOlat1;
http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent";>
%ISOsymbol;
http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent";>
%ISOspecial;
]>
EODT;

$doctype2 = 'http://gv.ca/dtd/character-entities.dtd";>';

$xml = ''.$doctype1.
   ' ';
$dom = new domDocument();
$dom->loadXML($xml);
echo $dom->saveXML();


The above code works as-is and the   is present in the huge output.
However, when I change it to use $doctype2 the   is no longer there
and returns the warning "Entity 'nbsp' not defined in Entity, line 1".
Of course the $doctype2 string is the one I need.

What am I doing wrong? Why isn't it loading the external entities? Is
there some other way of doing this that I somehow missed? I tested the
exact same xml code using "xmllint -format -loaddtd file.xml" and it
worked fine.

Tested on Gentoo with PHP 5.0.0 and 5.0.1 with libxml 2.6.11.

Any ideas would be appreciated.
Thanks,
-- 
David Numan <[EMAIL PROTECTED]>

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



Re: [PHP] DOM loadXML not loading doctype as expected in PHP5

2004-08-31 Thread David Numan
It worked! Thank you so much!

I couldn't find documentation for this anywhere. I think I will add a
note on the DOM Function page in the php docs.

-dave

On Tue, 2004-08-31 at 01:23, Christian Stocker wrote:
> On Tue, 31 Aug 2004 00:27:25 -0400, David Numan <[EMAIL PROTECTED]> wrote:
> > Hi
> > 
> > I'm working on a project using PHP5 and I'm using the DOM extension
> > quite heavily. I need to be able to store various character entities
> > such as $nbsp; and é Note: this is for a custom XML document, not
> > standard (X)HTML.
> > 
> > When I load my XML string into my domDocument I've been trying
> > variations of $doctype1 and $doctype2 below. Here is my code:
> > 
> > $doctype1 = << >  >  > "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent";>
> > %ISOlat1;
> >  > "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent";>
> > %ISOsymbol;
> >  > "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent";>
> > %ISOspecial;
> > ]>
> > EODT;
> > 
> > $doctype2 = ' > "http://gv.ca/dtd/character-entities.dtd";>';
> > 
> > $xml = ''.$doctype1.
> >' ';
> > $dom = new domDocument();
> > $dom->loadXML($xml);
> > echo $dom->saveXML();
> > 
> > The above code works as-is and the   is present in the huge output.
> > However, when I change it to use $doctype2 the   is no longer there
> > and returns the warning "Entity 'nbsp' not defined in Entity, line 1".
> > Of course the $doctype2 string is the one I need.
> > 
> > What am I doing wrong? Why isn't it loading the external entities? Is
> > there some other way of doing this that I somehow missed? I tested the
> > exact same xml code using "xmllint -format -loaddtd file.xml" and it
> > worked fine.
> 
> try if it works with
> 
> $dom->resolveExternals = true:
> 
> before $dom->load()
> 
> not tested, but I assume it has something to do with not loading
> external entities
> 
> chregu
> > 
> > Tested on Gentoo with PHP 5.0.0 and 5.0.1 with libxml 2.6.11.
> > 
> > Any ideas would be appreciated.
> > Thanks,
> > --
> > David Numan <[EMAIL PROTECTED]>
> > 
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> > 
-- 
David H. Numan, Software Architect
Guided Vision: Internet Application Construction
(905) 528-3095   http://guidedvision.com

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