Hallo,
ich habe folgendes Problem mit PHP5:
<?
$xml = '<?xml version="1.0" encoding="utf-8"?>
<root>
<x:test xmlns:x="http://foo"/>
</root>';
$dom = new DOMDocument;
$dom->loadXML($xml);
$xpath = new DOMXPath($dom);
echo $xpath->query("/root/x:test")->length;
?>
Das wirft nen Fehler "Undefined namespace prefix in...."
Dagegen funktioniert das hier einwandfei:
<?
$xml = '<?xml version="1.0" encoding="utf-8"?>
<x:root xmlns:x="http://foo">
<test/>
</x:root>';
$dom = new DOMDocument;
$dom->loadXML($xml);
$xpath = new DOMXPath($dom);
echo $xpath->query("/x:root/test")->length;
?>
Hat jemand eine Idee woran das liegen kann ?
Grüße
Thomas