Search code examples
phpxmldomsimplexmltagname

PHP retrieving XML tagnames


i am actually new with these XML stuff. I do understand things about the DOMDocument,DOMNOdeList and etc using http://www.php.net/manual/en/intro.dom.php

so here is the problem..

http://jobhits.co.uk/services/rss?k=job

the feed above returns an XML document. i can successfully retrieve tag names like title,description and link using these codes

$doc->load('http://jobhits.co.uk/services/rss?k=job');
$items = $doc->getElementsByTagName("item");

foreach($items as $item){
    $titles[] = $item->getElementsByTagName("title");
}

the problem is there is a certain 'tagname-like' in that document

<a10:updated></a10:updated>

i tried getting that using

$update[] = $item->getElementsByTagName("a10:updated");

..which is a failure

here is a sample xml http://piratelufi.com/ark/gettagname.xml or you can use the string inside load method above :)

btw i can't use simpleXML and predefined classes as much as possible thanks :D


Solution

  • You are looking for getElementsByTagNameNS,