I have being messing about with DOM XPath stuff all day – reading around and tearing my hair out! So, last resort, ask you guys – the pros!
What I’m trying to do is retrieve (in an array) of all the titles of threads here.
I am trying to use XPath to do it (unless someone can tell me a better way); currently I am just trying to get just 1 title to check whether my code is working (clearly not!…)
I’m using:
$list3 = $xpath3
->evaluate("//a[contains(@style, 'font-weight:bold') and
contains(@href, 'showthread.php?t=3499047')]");
However nothing is getting retrieved
The reason you are not getting any results is that there is no
<a>elements that satisfy both conditions.These are the links containing “3499047” in @href:
As you can see, none of them contain “‘font-weight:bold'” in a style attribute.
In case the markup on the page has elements with your desired combination when you view it in a browser, they might have been added via javascript. DOM will not run any JavaScript, so you have to check the markup fetched with DOM.