This is my xml file
<CATALOG>
<category>
<name>Engineering</name>
<subject>Civil Works</subject>
<subject>Water Supply</subject>
<subject>Street Lighting</subject>
</category>
<category>
<name>Public Health</name>
<subject>Sanitation</subject>
<subject>Dispensaries</subject>
<subject>Maternity Services</subject>
</category>
<category>
<name>Town Planing</name>
<subject>T.P.S</subject>
<subject>T.P.B.O</subject>
<subject>Tracer</subject>
<subject>Chairmen</subject>
</category>
<category>
<name>Administration</name>
<subject>Ministerial Manager</subject>
<subject>Revenue R.O.</subject>
<subject>Accounts Accountant</subject>
</category>
</CATALOG>
I have to get the all subject names in category spesified by $_GET["category"];
and i wrote the code as follows.
<?php
$xml = simplexml_load_file("../category.xml");
$subjects = 'Hello';
$categoryes=$xml->xpath('/category');
foreach($categoryes as $name)
{
echo $name;
if($name == $_GET["category"] )
{
foreach($xml->chaildren() as $child)
{
$subjects = $subjects." ".$child;
}
}
}
echo $subjects;
?>
what wrong with this code?
thank you.