[SOLVED] DOM XML php code
Posted: Wed Mar 02, 2005 3:46 pm
I write myself code for populating an xml document with records:
My xml file is:
i try to select its titles but i can't my code is
html...
<select name="select" class="style1">
</select>
...html
But my code is not right as it produces :
XPathObject Object ( [type] => 1 [nodeset] => Array ( ) )
Can anyone help me please?
Thanx a lot!
My xml file is:
Code: Select all
<root>
<Library>
<Creator>aaaaaaaaaaaaaaaaaa</Creator>
<Title>aaaaaaaaaaaaaaaaaaaaa</Title>
<Description>aaaaaaaaaaaaaaaaaaaaaa</Description>
<Description.audience>Pregraduate</Description.audience>
<Description.contents>aaaaaaaaaaaaaaaaaaaaaaaaaaaa</Description.contents>
<Description.respsite>akm</Description.respsite>
<Description.url>http://www.in.gr</Description.url>
<Date.Created>28-02-2005 17:44:36</Date.Created>
<Date.Modified>28-02-2005 17:44:36</Date.Modified>
</Library>
<Library>
<Creator>bbbbbbbbbbb</Creator>
<Title>bbbbbbbbbbbbbbbb</Title>
<Description>aaaaaaaaaaaaaaaaaaaaaa</Description>
<Description.audience>Pregraduate</Description.audience>
<Description.contents>aaaaaaaaaaaaaaaaaaaaaaaaaaaa</Description.contents>
<Description.respsite>akm</Description.respsite>
<Description.url>http://www.in.gr</Description.url>
<Date.Created>28-02-2005 17:48:52</Date.Created>
<Date.Modified>28-02-2005 17:48:52</Date.Modified>
</Library>
</root>html...
<select name="select" class="style1">
Code: Select all
<?php
//retrieve the second element with name employee
//$root = $doc->getElementsByTagName('root')->item(0);
$doc = domxml_open_file('lessons.xml');
//$doc->validateOnParse = true;
$xpath = $doc->xpath_new_context();
$a = $xpath->xpath_eval("///title");
while(isset($aї$i])){
echo '<option value="'.$aї$i].'">'.$i.'. '.$aї$i].'</option>';
}
?>...html
But my code is not right as it produces :
XPathObject Object ( [type] => 1 [nodeset] => Array ( ) )
Can anyone help me please?
Thanx a lot!