PHP DOMDocument:根据tag,id和class name获取nodeValue

I saved a reference of a DOM element on a page, the same way Chrome dev show them, such as:

<span id="myId" class="myClass1 myClass2">my content</span>

to be represented like:

$reference = 'span#myId.myClass1.myClass2';

based on this value, I'd like to be able to retrieve "my content", knowing that based on the value I may have either no ID, or no CLASS.

I was exploring the domxpath option but haven't been able to find a way through the queries.

can someone help me with this ?

thanks