मैं इस तरह एक XML के साथ काम कर रहा हूँ: (यह एक ePub किताब में एक मानक container.xml है)क्या PHPNOMPath में रजिस्टर नेमस्पेस आवश्यक है?
<?xml version="1.0"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/9780765348210.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
मैं PHP का उपयोग कर इसे पार्स करने के लिए कोशिश कर रहा हूँ। यह मेरा कोड अब तक है:
$c = new DOMDocument();
$c->load($filename);
$x = new DOMXPath($c);
//fine up to here!
//is this even what I'm supposed to be doing?
$x->registerNamespace('epub', 'urn:oasis:names:tc:opendocument:xmlns:container');
$root = $x->query('/epub:container/epub:rootfiles/epub:rootfile');
//fine down from here!
$opf = $root->item(0)->getAttribute('full-path'); //I know I should check if the element's there and if it has the attribute. Not important.
मेरा प्रश्न है: वहाँ एक तरीका है कि registerNamespace
कॉल करने के लिए नहीं है? मुझे यकीन नहीं है कि अलग-अलग एपबस इस मान को थोड़ा अलग तरीके से सेट करते हैं, और मुझे इस कोड को उस एपब पर काम करने की आवश्यकता है जिसे मैं फेंकता हूं।