Dieser Code funktionierte und als wir auf PHP 5.3.10 aktualisierten, hörte es auf zu arbeiten und fing an, einige wirklich merkwürdige Fehler zu werfen.Aktualisiert auf PHP 5.3.10 und simpleXMLelement ist defekt
Die ursprüngliche XML validiert auf w3c.org ohne Fehler, aber ich habe die Website aus Gründen der Kürze und Sicherheit speziell bearbeitet.
Die XML (der Kürze halber bearbeitet, aber Fehler in Zeile 1 hergestellt):
<AmberAlertDirective
xmlns="http://www.hidden.com/AmberAlert"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hidden.com/en_US/AmberAlert.xsd">
<Directive>New</Directive>
<AmberAlertId>9969</AmberAlertId>
<MessageTimestamp>2012-03-27T00:35:11</MessageTimestamp>
<AmberAlert>
<Target>
<State Code="OH">
</State>
</Target>
</AmberAlert>
</AmberAlertDirective>
Die PHP-Fehler von error_log:
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: Entity: line 2: parser error : AttValue: " or ' expected in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: xmlns=\"http://www.missingkids.com/amber/NCMECAmberAlert\" in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: ^in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: Entity: line 2: parser error : attributes construct error in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: xmlns=\"http://www.missingkids.com/amber/NCMECAmberAlert\" in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: ^in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: Entity: line 2: parser error : Couldn't find end of Start Tag AmberAlertDirective line 1 in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: xmlns=\"http://www.missingkids.com/amber/NCMECAmberAlert\" in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: ^in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: Entity: line 2: parser error : Extra content at the end of the document in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: xmlns=\"http://www.missingkids.com/amber/NCMECAmberAlert\" in /aa.php on line 125
PHP Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: ^in /aa.php on line 125
PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /aa.php:125
Stack trace:
#0 /aa.php(125): SimpleXMLElement->__construct('<AmberAlertDire...')
#1 /AAServlet.php(64): processAmber('<AmberAlertDire...')
#2 {main}
thrown in /aa.php on line 125
Und falls jemand bei der Arbeit ist, ist die URL in der XML wahrscheinlich nsfw. – halfer
Vielleicht versuchen Sie Beispiel 1 von http://www.php.net/manual/en/simplexml.examples-errors.php, um zu sehen, ob der XML-Parsing-Fehler beschreibender ist. – cOle2