- simplexml_load_string: documentation ( source)
<?php
$str=<<<XML
<configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup>
<appSettings>
<!-- timeout in seconds -->
<add key="AtgStartTimeout" value="20" />
<add key="EnableHermesLogging" value="true" />
<add key="HandleIOSDevices" value="true" />
<add key="UseAMCLoyalty" value="false" />
</appSettings>
</configuration>
XML;
$xml=simplexml_load_string($str);
$result=$xml->xpath('//configuration//appSettings//add[@key="UseAMCLoyalty"]/..');
foreach($result as $node)
{
echo $node->attributes()->key."\n";
}