1

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

kapitanluffy
  • 1,269
  • 7
  • 26
  • 54
  • Earlier: [How read < abc: xyz > xml tag using php?](http://stackoverflow.com/q/3130605/367456) – hakre Apr 09 '13 at 07:58

2 Answers2

2

You are looking for getElementsByTagNameNS,

Wrikken
  • 69,272
  • 8
  • 97
  • 136
2

The a10 jsut denotes, that the element updated is from a different namespace. The colon : is a special character in this context. In the beginning of your sample xml (the latter url) one finds the definition of this namespace: <rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">. So You need getElementsByTagNameNS. I presume something along the lines of: getElementsByTagNameNS("http://www.w3.org/2005/Atom","updated")might help.

Dilettant
  • 3,267
  • 3
  • 29
  • 29