: (bir epub kitapta standart container.xml var)Kayıt ol PHP'nin DOMXPath'ında gerekli alan mı? Böyle bir XML ile çalışıyorum
<?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 kullanarak bunu ayrıştırmak çalışıyorum. Bu benim kod şimdiye kadar geçerli:
$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.
Sorum şu: olduğunu registerNamespace
çağrıyı yapmak değil bir yolu var mı? Farklı epubların bu değeri biraz farklı olarak ayarlayıp ayarlamadığından emin değilim ve bu koda ihtiyacım var.