New DOM XML problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

New DOM XML problem

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try var_export($keywords) just after the call to get_elements_by_tagname()
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Since I only see a code fragment, where does $doc get initialized?
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

dimitris, you can edit your posts..
Post Reply