Page 1 of 1

New DOM XML problem

Posted: Wed Mar 02, 2005 8:50 pm
by dimitris
In my file

Code: Select all

<root>
<Library>
<Creator>alalalalal</Creator>
<Title>lalalalalala</Title>
<Description>Yeap</Description>
<Description.audience>Postgraduate</Description.audience>
<Description.contents>YopYpYopYop</Description.contents>
<Description.keywords>Hi</Description.keywords>
<Description.keywords>He</Description.keywords>
<Description.keywords>Hy</Description.keywords>
<Description.respsite>Soso</Description.respsite>
<Description.url>sisi</Description.url>
<Date.Created>03-03-2005 4:17:51</Date.Created>
<Date.Modified>03-03-2005 4:17:51</Date.Modified>
</Library>
</root>
i have many keywords and by using this code:

Code: Select all

$i=0;
$keywords = $doc->get_elements_by_tagname("Description.keywords");
				$keywords = $keywords&#1111;$i];//i use $i to choose the result
				$keywords = $keywords->get_content();//Problem
i get an error:
Fatal error: Call to a member function on a non-object in /home/user1/public_html/xml/view.php on line 63

Does anyone now how can i modify my code to store the Description.keywords of my choice in an array which i can lately use to show its contents?

Thanks a lot!

Posted: Wed Mar 02, 2005 10:25 pm
by feyd
try var_export($keywords) just after the call to get_elements_by_tagname()

Posted: Wed Mar 02, 2005 11:23 pm
by smpdawg
Since I only see a code fragment, where does $doc get initialized?

Posted: Thu Mar 03, 2005 6:42 am
by dimitris
smpdawg wrote:Since I only see a code fragment, where does $doc get initialized?
i have firstly

Code: Select all

$dom = domxml_open_file('lessons.xml');
$doc = $dom -> document_element();
which initialises the $doc variables

Posted: Thu Mar 03, 2005 8:05 am
by feyd
dimitris, you can edit your posts..