ID:               28339
 Comment by:       becharakordahi at hotmail dot com
 Reported By:      cwood at austin dot rr dot com
 Status:           Bogus
 Bug Type:         SimpleXML related
 Operating System: Mac OS X 10.2.8
 PHP Version:      5.0.0RC2
 New Comment:

I am a student learning php and xml .
And I have difficulty by resolving some problems such as

when I use "simplexml_load_string()" function 
I have this error: 

Fatal error: Call to undefined function: simplexml_load_string() in
c:\inetpub\wwwroot\E_Learning\PHP\tryout\tt.php on line 14
this is the code i try :
<?php
$string = <<<XML
<?xml version='1.0'?> 
<document>
<title>Forty What?</title>
<from>Joe</from>
<to>Jane</to>
<body>
  I know that's the answer -- but what's the question?
</body>
</document>
XML;

$xml = simplexml_load_string($string);

var_dump($xml);
?> 

how can I resolve this problem


Previous Comments:
------------------------------------------------------------------------

[2004-05-09 23:58:43] cwood at austin dot rr dot com

DOH! Thanks. PHP rocks.

------------------------------------------------------------------------

[2004-05-09 23:53:15] [EMAIL PROTECTED]

&nbsp; is not a defined XML entity. In XML, you can only 
use &lt;, &gt;, &amp;, &quot; and &apos;. For other 
entities you must use numeric character references. See:

http://www.w3.org/TR/REC-xml/#syntax

------------------------------------------------------------------------

[2004-05-09 21:29:06] cwood at austin dot rr dot com

Description:
------------
When trying to load a string containing an HTML-encoded 
non-breaking space ("&nbsp;") with 
simplexml_load_string, I get the following warning:

Warning:  Entity: line 14: error: Entity 'nbsp' not 
defined in /Library/WebServer/Documents/simple.php on 
line 11
 
But other HTML-escaped characters like &gt; and &lt; 
make it through fine.

Reproduce code:
---------------
<?php
$xmlstr = <<<XML
<?xml version='1.0'?>
<rss>
<channel>
<item>
 <title>This is the title</title>
 <link>http://globelogger.com</link>
 <description>This&nbsp;is the description</description>
</item>
</channel>
</rss>
XML;

$xml = simplexml_load_string(utf8_encode($xmlstr)); 
foreach($xml->channel->item as $item) { 
echo "<b><a
href=".$item->link.">".$item->title."</a></b><br>".$item->description."<p>";
}
?>

Expected result:
----------------
<b><a href=http://globelogger.com>This is the title</
a></b><br>This is the description<p>

Actual result:
--------------
Warning:  Entity: line 7: error: Entity 'nbsp' not 
defined in /Library/WebServer/Documents/test.php on 
line 15
 
 Warning:   This�is the description in /Library/
WebServer/Documents/test.php on line 15
 
 Warning:                          ^ in /Library/
WebServer/Documents/test.php on line 15
 
 Warning:  Invalid argument supplied for foreach() in /
Library/WebServer/Documents/test.php on line 16


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28339&edit=1

Reply via email to