- simplexml_load_string: documentation ( source)
<?php
$xmlString = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetDataResponse xmlns="urn:com:esi911:webeoc7:api:1.0">
<GetDataResult>
<data>
<record dataid="6" county="Fayette County" title="Title goes here" description="Description goes here." status="Inactive" />
<record dataid="5" county="Caldwell County" title="Title goes here" description="Description goes here." status="Inactive" />
<record dataid="4" county="Burnet County" title="Title goes here" description="Description goes here." status="Active" />
<record dataid="2" county="Blanco County" title="Title goes here" description="Description goes here." status="Active" />
<record dataid="1" county="Bastrop County" title="Title goes here" description="Description goes here." status="Active" />
</data>
</GetDataResult>
</GetDataResponse>
</soap:Body>
</soap:Envelope>
XML;
$xml = simplexml_load_string($xmlString);
$xml->registerXPathNamespace('urn', 'urn:com:esi911:webeoc7:api:1.0');
$records = $xml->xpath('//urn:record');
echo (string)$records[0]->attributes()->dataid;