Return specific HREF attribute using Xpath query
- by Michael Pasqualone
Having a major brain freeze, I have the following chunk of code:
// Get web address
$domQuery = query_HtmlDocument($html, '//a[@class="productLink"]');
foreach($domQuery as $rtn) {
$web = $rtn->getAttribute('href');
}
Which obviously gets the entire href attribute, however I only want 1 specific attribute within the href. I.e. If the href is: /website/product1234.do?code=1234&version=1.3&somethingelse=blaah
I only want to return the variable for "version", so wish to only return "1.3" in my example. What's most efficient way to do this?