I'm parsing xml document using DOMDocument class. First I've selected all nodes with name 'item' using $xml->getElementsByTagName('item')
method. My sample xml file looks like this:
<item>
<title>...</link>
<description>...</description>
<pubDate>...</pubDate>
<ns:author>...</dc:creator>
</item>
However my problem is getting value from nested tag with namespace name with colon sign. I get values from nodes without namespaces in foreach
using $node->getElementsByTagName('description')->item(0)->nodeValue
and there is no errors.
I also found method getElementsByTagNameNs() to get nodes with it's namespaces. However when i try to get nodeValue like previous nodes without namespace I get "PHP Notice: Trying to get property of non-object". I think it is strange because getElementsByTagNameNs()->item(0)
returns object DOMElement.
Do you know how to take value from node with namespace, in this case <ns:author></dc:creator>
element?