我的XML:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:admin="http://webns.net/mvcb/" xmlns:doap="http://usefulinc.com/ns/doap#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdf:Description rdf:about="">
<admin:generatorAgent rdf:resource="http://purl.org/NET/erdf/extract"/>
</rdf:Description>
<rdf:Description rdf:about=""/>
<rdf:Description rdf:about="#oryx_9A42131E-B88E-41D6-A3C4-A681F2BC93F7">
<type xmlns="http://oryx-editor.org/">Collapsed</type>
</rdf:Description>
</rdf:RDF>
我需要标记rdf:Description
尝试:
1)使用儿童功能 -
我将$ rootelement初始化为SimpleXML对象:
foreach ($rootelement->children("rdf",TRUE)->Description as $element) {
var_dump($element->type); //This doesnt work
var_dump((string)$element->type); //Even this doesnt work
}
2)使用xpath查询 -
foreach($rootelement->xpath('//rdf:Description') as $event) {
var_dump($event->xpath('rdf:type'));//Not working
var_dump($event->xpath('type'));//Still not working
}
任何想法我怎样才能做到这一点?