User4834426
User4834426

Reputation: 101

How to read utf-8 encoded XML file in PHP?

Code was working fine & was getting values from XML file and was generating form of those values . I added encoding="UTF-8" to XML tag. And It is giving following warnings and error. Thank you in adavance

Warning: DOMDocument::load(): parsing XML declaration: '?>' expected in file:///C:/xampp/htdocs/Urdu/english.xml, line: 1 in C:\

Warning: simplexml_load_file(): english.xml:1: parser error : parsing XML declaration: '?>' expected in C:\

Warning: simplexml_load_file(): <?xml version="1.0" standalone="yes" encoding="UTF-8"?> in C:\xampp\htdocs\Urdu\getxmlform.php on line 64

Warning: simplexml_load_file(): ^ in C:\xampp\htdocs\Urdu\getxmlform.php on line 64

Catchable fatal error: Argument 1 passed to makeNodeField() must be an instance of SimpleXMLElement, boolean given, called in C:\ on line 66 and defined in C:\

Upvotes: 0

Views: 928

Answers (1)

Ja͢ck
Ja͢ck

Reputation: 173652

Your XML declaration line is invalid:

<?xml version="1.0" standalone="yes" encoding="UTF-8"?>
                   ^^^^^^^^^^^^^^^^^

Move the underlined portion to the back and it will parse properly:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

Upvotes: 1

Related Questions