Jump to content

Get tag value from XML using PHP


pbvamsi

Recommended Posts

My XML file looks like

<entry>
    some tags 
    <title type='text'> content to be extracted </title>
    <content type='text'> content to be extracted </content>    
</entry>

 

(there will be 3-4 titles and descriptions in each entry tag, bt i want only whose type is text) i used

 

$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadXML("kFeed.xml");
$entryTag = $dom->getElementsByTagName("entry")->item(0);
$title = $entryTag->getElementsByTagName("title")->item(0)->nodeValue;
$descr = $entryTag->getElementsByTagName("content")->item(0)->nodeValue;

the error i get is

 

Fatal error: Call to a member function getElementsByTagName() on a non-object 

 

can someone help me to fix this problem. thanks

 

Link to comment
https://forums.phpfreaks.com/topic/255867-get-tag-value-from-xml-using-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.