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

1

2 Answers 2

2

You are looking for getElementsByTagNameNS,

Sign up to request clarification or add additional context in comments.

2 Comments

fail question guess i haven't read it very well. thank you very much :)
Well, namespaces are the default problem anyone encounters when just starting out with xml/DOM, you are in good company :)
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.

1 Comment

well explained i'll up this one. so that's what namespaces are in XML xD thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.