0
votes

Iam new to xpath. I got a url using curl and domdocument but the problem is that the link is formated in this way: /bookstore/book.php So then I wanna echo it to my own href link, it doesnot work ofcourse. The awnser would be to make a variable thats contains both the www.hello.com and the link I got from domdocument.

Here is my line of code:

$link = $linkquery->item(2)->nodeValue;

But if I do this it just gives me an 0

$url = "http://www.hello.com" + $link;

Any ideas? I guess I have missed something basic.

Regards

EDIT

Thanks for the help, the awnser was $url = "http://www.hello.com$link";

1
Please add your XML and the XPath expression to your question. And you should use $xpath->evaluate('string(//nodename[3])'), not $xpath->query('//nodename')->item(2)->nodeValue; - ThW
oh okey! thanks I will fix that :) - Joakim Johansson

1 Answers

0
votes

Isn't the string concatenation operator in PHP the dot operator .? So you want $url = "http://www.hello.com" . $link; or simply $url = "http://www.hello.com$link";.