Dear friends of linuxquestions.org;
I'm struggling with a very irritating problem:
I have a xml file and I read it within a php file with XML dom.
This is the node structure of my xml file :
<Root>
<name></name>
<surname></surname>
<ID></ID>
<department></department>
<rank></rank>
<telNo></telNo>
<deckNo></deckNo>
<mobileNo secrecy="c"></mobileNo>
<homeTelNo secrecy="c"></homeTelNo>
</Root>
Here are the php code of mine:
Code:
$in_name = $_POST["name"];
$in_surname = $_POST["surname"];
$in_department = $_POST["department"];
$doc = new DOMDocument();
$doc->load('http://localhost/xampp/tsbs_yellow_pages/run/1/databank.xml');
$xPath = new DOMXPath($doc);
if($in_name != '')
{
$nodeList = $xPath->query('//User/name');
$phase = trim(($in_name));
$length_of_phase = strlen($phase);
}
foreach($nodeList as $node)
{
if( strncasecmp( trim($node->nodeValue),$phase,$length_of_phase) == 0)
{
$parent_nodes = $node->parentNode;
//Here is the point
for($i = 1; $i <= 4; $i++)
{
echo("<p>$parent_nodes->nodeValues</p>\n");
}
}
}
In the comment line, I've got the parent node of the current node. Parent node is "User" node. I would like to obtain the children of this parent node, say "name","surname " etc. How can I do this? Is there any function such as : "$parent_nodes->bringChildren('name')". I could not find it.
Thanks in advance.