<?php
// pretend these are the vars coming in
$_GET['name'] = 'England';
$_GET['area'] = 'Cleveland';
$_GET['type'] = 'Homocide';
$xmlstr = <<<XML
<?xml version='1.0' encoding='UTF-8'?>
<crimes year='2013' xmlns:xsi="http://w...content-available-to-author-only...3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="stats.xsd">
<data country='England' region='North East Region' area='Cleveland'>
<heading name='Victim-based crime'>
<category name='Violence against the person'>
<number type='Homocide' total='3'/>
<number type='Violence with injury' total='3737'/>
<number type='Violence without injury' total='2630'/>
</category>
<category type='Sexual offences' total='563' />
<category type='Robbery' total='259' />
<category type='Theft offences'>
<number type='Burglary' total='4561' />
<number type='Domestic Burglary' total='2054' />
<number type='Non-domestic burglary' total='2057' />
<number type='Vehicle offences' total='3329' />
<number type='Theft from the person' total='372' />
<number type='Bycycle theft' total='994' />
<number type='Shoplifting' total='5174' />
<number type='All other theft offences' total='5381' />
</category>
<category type='Criminal damage and arson' total='7934' />
</heading>
<heading name='Other crimes against society'>
<category type='Drug offences' total='2116' />
<category type='Possession of weapons offences' total='267' />
<category type='Public order offences' total='1342' />
<category type='Miscellaneous crimes against society' total='405' />
<category type='Fraud' total='405' />
</heading>
</data>
</crimes>
XML;
'/crimes/data[@country="%s"][@area="%s"]/heading/category/number[@type="%s"]',
$_GET['name'],
$_GET['area'],
$_GET['type']
);
$nodeList = $xml->xpath($xpath);
echo 'Total: ', $nodeList[0]['total'];