I have a xml file:
<kemo>
<cities>
<area>area1</area >
<city>city1</city>
<status>Lipsum1</status>
</cities>
<cities>
<area>area1</area >
<city>city2</city>
<status>Lipsum2</status>
</cities>
<cities>
<area >area2</area >
<city>city3</city>
<status>Lipsum3</status>
</cities>
<cities>
<area >area2</area >
<city>city4</city>
<status>Lipsum4</status>
</cities>
<cities>
<area >area2</area >
<city>city5</city>
<status>Lipsum5</status>
</cities>
</kemo>
I can walk trough this xml with simlpeXML, but I dont want to repeat area names. I want a tree like this:
area1 city1
city2
area2 city3
city4
city5
with
$request_url = "xml.xml";
$xml = simplexml_load_file($request_url) or die("feed not loading");
foreach($xml->kemo as $value){
echo '<li><span>'.$value->area.' '.$value->city.'</span></li>';
}
I have repeated area. How can I prevent repeating child? Thanks in advanced