I m parsing xml using php.I want to retrieve DISTINCT CATEGORY VALUES from xml below.My php code is generating duplicate values.I dont know where i am wrong.My code looks like this: XML:\[code\] <?xml version="1.0" standalone="yes"?> <Rows> <Row Code="10004" Name="Product1" Category="Mobiles" /> <Row Code="10006" Name="Playstation" Category="Consoles" /> <Row Code="10008" Name="Crysis" Category="Games" /> <Row Code="10009" Name="Gears of War" Category="Games" /> <Row Code="10009" Name="Xbox" Category="Consoles" /> </Row>\[/code\]My php code looks like this:\[code\] $xml = simplexml_load_string(file_get_contents('XML/products.xml')); $prifix = '/shop/listings/' ; $cat=""; $code=""; $attr=""; $cat->cat=""; foreach ($xml as $row) { $attr = $row->attributes(); if ($cat->cat!=$attr->Category) printf('<li>%s</li>', anchor($prifix . $attr->Code, $attr->Category)); $code=$attr->Code; $cat->cat=$attr->Category; }\[/code\]I dont know how can i avoid duplication in "Category" and just want results like this :MobilesConsolesGamesI want unique value for "Category" without any repetition but dont know where i am making mistake.Please help me.Thanks