Jump to content

Need Help with DOMXpath


Recommended Posts

so i am trying to make my api for a website, and started coding a script for it.


so far it looks like this


curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$rt = curl_exec($ch);
$dom = new DOMDocument();
$xpath = new DOMXpath($dom);
// title ("//h1[@class=textLarge7 extratextLarge7]/text()")
$titleQuery = $xpath->query("//h1[@class=textLarge7 extratextLarge7]/text()");
echo $titleQuery;



the problem is that when i try to echo it it wont give me the title ( only an error on line 17, that is the last line )
if it helps you when i try to execute print_r it gives me DOMNodeList Object ( )
Sorry for my bad english, its not my native language


Edited by hieK
Link to comment
Share on other sites

So now i have another problem,


<ul class="listType1 marginTop1">
<li itemprop="ingredients">13/4 pahar faina de naut</li>
<li itemprop="ingredients">3/4 lingurita de sare</li>
<li itemprop="ingredients">3/4 lingurita cardamon macinat marunt</li>
<li itemprop="ingredients">1/2 lingurita piper negru macinat</li>
<li itemprop="ingredients">11/2 pahare de apa</li>
<li itemprop="ingredients">4 linguri ulei de masline</li>
i cant figure out how to write the xpath query
$ingredientsQuery = $xpath->query("//ul[@class=listType1 marginTop1]/text()"); but how do i integrate the li ?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.