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

 ID:                 53694
 Updated by:         rricha...@php.net
 Reported by:        jamone_95134 at yahoo dot com
 Summary:            SimpleXMLElement does not read XML declaration line.
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            SimpleXML related
 Operating System:   Windows XP
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

invalid characters before start of declaration.


Previous Comments:
------------------------------------------------------------------------
[2011-01-08 10:04:15] jamone_95134 at yahoo dot com

Description:
------------
---

>From manual page: http://www.php.net/simplexml.examples-basic

---

When I run the first example I get the following errors:



$ php test1.php



Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error :
XML 

declaration allowed only at the start of th

e document in D:\php_src\XML\test1.php on line 4



Warning: SimpleXMLElement::__construct():       <?xml version="1.0" 

encoding="utf-8"?> in D:\php_src\XML\test1.php on li

ne 4



Warning: SimpleXMLElement::__construct():            ^ in 

D:\php_src\XML\test1.php on line 4



Fatal error: Uncaught exception 'Exception' with message 'String could
not be 

parsed as XML' in D:\php_src\XML\test1.php

:4

Stack trace:

#0 D:\php_src\XML\test1.php(4): SimpleXMLElement->__construct('?<?xml 

version=...')

#1 {main}

  thrown in D:\php_src\XML\test1.php on line 4





If I remove the <?xml version="1.0" encoding="utf-8"?> line from the
example.php 

file it runs ok.



So how do we handle the declaration line for xml files with
SimpleXMLElement?

Test script:
---------------
Just running example 2 from
http://www.php.net/manual/en/simplexml.examples-basic.php

Expected result:
----------------
Expected result:



So, this language. It's like, a programming language. Or is it a

scripting language? All is revealed in this thrilling horror spoof

of a documentary.

Actual result:
--------------
$ php test1.php



Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error :
XML 

declaration allowed only at the start of th

e document in D:\php_src\XML\test1.php on line 4



Warning: SimpleXMLElement::__construct():       <?xml version="1.0" 

encoding="utf-8"?> in D:\php_src\XML\test1.php on li

ne 4



Warning: SimpleXMLElement::__construct():            ^ in 

D:\php_src\XML\test1.php on line 4



Fatal error: Uncaught exception 'Exception' with message 'String could
not be 

parsed as XML' in D:\php_src\XML\test1.php

:4

Stack trace:

#0 D:\php_src\XML\test1.php(4): SimpleXMLElement->__construct('?<?xml 

version=...')

#1 {main}

  thrown in D:\php_src\XML\test1.php on line 4




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



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

Reply via email to