max_maggot Posted July 20, 2015 Share Posted July 20, 2015 <div class="price-box"> <span class="regular-price" id="product-price-13129" itemtype="http://schema.org/Offer" itemscope="" itemprop="offers"> <span class="price" itemprop="price">$9.80</span> </span> </div> Hi all, In the above HTML code I am using the following xpath query to try and retrieve the price value ($9.80). I can't seem to get the query correct. Here is what I have come up with so far $items[price] = $xpath->query("//div[@class='price-box']//span/[@class='regular-price']//span/[@class='price']")->item(0)->textContent; //Get and Set price Any help or direction would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted July 20, 2015 Solution Share Posted July 20, 2015 Remove the forward slash after span in your xpath $items[price] = $xpath->query("//div[@class='price-box']//span[@class='regular-price']//span[@class='price']")->item(0)->textContent Quote Link to comment Share on other sites More sharing options...
max_maggot Posted July 20, 2015 Author Share Posted July 20, 2015 Figured it out myself. I should have taken 5 more minutes $items[price] = $xpath->query("//div[@class='price-box']/span[@class='regular-price']/span[@class='price']")->item(0)->textContent; Quote Link to comment Share on other sites More sharing options...
max_maggot Posted July 20, 2015 Author Share Posted July 20, 2015 Thanks for your answer Ch0cu3r. I found a xpath query generator and noticed the mistake. http://xmltoolbox.appspot.com/xpath_generator.html Thanks for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.