使用XML中的php特定参数查找

Hello i have the follow problem.

I have e XML file and i know the value of "uniquename=value2". I want extract the value of URL.

<set uniquename="value1">
  <items>
    <item>
      <units>
         ...
      </units>
    </item>
    <item>
      <units>
        ...
        <url>http://www.something</url>
        ...
      </units>
    </item>
  </items>
 </set>
 <set uniquename="value2">
  <items>
    <item>
      <units>
         ...
      </units>
    </item>
    <item>
      <units>
        ...
        <url>http://www.something2</url>
        ...
      </units>
    </item>
  </items>
 </set>

Someone has suggestions?

Thanks to all.

You can do it simply with simplexml and xpath:

$x = simplexml_load_string($xml);
$nodes = $x->xpath('set[@uniquename="value2"]/items/item/units/url');

$url = (string)$nodes[0];