There is a path to the element

//div[@id='product_option_id']/text() 

It turns out this result: Product ID: 22826

Html for it

 <div class='item-last' id='product_option_id'>Product ID: 22826</div> 

How to use XPath to get only 22826 without "Product ID:"?

    1 answer 1

    With XPath in any way, the text should be broken or replaced with 'Product ID:':

     echo end(explode(': ', $text)); 

    or

     echo str_replace('Product ID: ', '', $text); 
    • maybe with some text () [1] or last (), I just don’t know how to apply them correctly :( - Ksu Lyguta
    • Here, by analogy with all DOM parsers, the content of the element is one string and you need to continue working with it manually. In your case, text () will return a text variable. - Artem Gorlachev
    • I see, thanks! - Ksu Lyguta