jQuery-like selectors for PHP DOMDocument

I’m working with a DOMDocument, and I’m wondering if there exists some way of using CSS-like selectors to select nodes like we would in jQuery.

Example situation: I’m parsing an XML file, one snippet of which looks like this:

    <gesmes:subject>Reference rates</gesmes:subject>
        <gesmes:name>European Central Bank</gesmes:name>
        <Cube time="2009-07-13">
            <Cube currency="USD" rate="1.3975"/>
            <Cube currency="JPY" rate="129.03"/>
            <Cube currency="BGN" rate="1.9558"/>
            <Cube currency="CZK" rate="26.028"/>

Accessing this structure with jQuery-like selectors would be dead simple. For example, I could use


to retrieve all the Cube elements with the ‘currency’ attribute.

But how can I do the same thing with PHP’s DOMDocument? I’d like to select elements which have an attribute, or have a particular attribute value.

jQuery-like selectors for PHP DOMDocument