Getting the content of node based on a set of attributes

Hello there,

I’m working of an web service API that gives me an XML like below. I’m wondering if there is an easy way to access the content of each <DATA> nodes based on the attributes. Most of the time I only need to access one of the nodes like <DATA type=“extra” id=“uid”>ab468d02ef</DATA>.

<TYPE>Data type name</TYPE>
<DATA type=“attribute” id=“1”>Boris</DATA>
<DATA type=“attribute” id=“2”>Johnson</DATA>
<DATA type=“attribute” id=“3”>Mr.</DATA>
<DATA type=“extra” id=“state”>published</DATA>
<DATA type=“extra” id=“date”>2012-01-23</DATA>
<DATA type=“extra” id=“uid”>ab468d02ef</DATA>

So far I looped through it with a script like below but I feel it’s bulky and not very efficient. Is there any good way to get the content of just one node?

foreach ($xml->RECORD as $record) {
  foreach($record->DATA[0]->attributes() as $name => $value)
    if ($name == "id")
      $UID= $value;


Start investigating into xPath?