below is the chunk of XML i get as input and i need to select the phone number found in the (732) 462-13112 node if the span in this sample code fed.com is empty.
i am starting off with xpath to ferret out the only certainty i see in the XML and that is “//nobr” how can i navigate down to the span containing ted.com and test to see if there is anything present?
<div>
<div></div>
<span class="pp-headline-item pp-headline-phone">
<span class="telephone" dir="ltr">
<nobr>(732) 462-1311</nobr>
<span class="pp-headline-phone-label" style="display:none">()</span>
</span>‎
</span>
<span> · </span>
<span class="pp-headline-item pp-headline-authority-page">
<span>
<a href="http://maps.google.com/local_url?q=http://www.federicis.com/&dq=07746+pizza">
<span>fed.com</span>
</a>
</span>
</span>
</div>
If I understand your question correctly, you can use the following:
This will return the phone number found in nobr if the span containing fed.com is empty, otherwise it will return an empty string.
Edit:
If you have multiple a tags under the main div, you can use this to extract the specific span: