The Xpath & PHP code below checks to see if the text in any of the "name" elements in the XML file contain the string "desk" (see the second line of code). If the Xpath search string was "Desk" (with an uppercase D) it would retrieve the text in the first XML name element which is "Desktop". But since the Xpath search string is "desk" (with a lowercase d) nothing is retrieved.
Is there a way to code this so the Xpath search string "desk" (with a lower case d) can retrieve "Desktop" (with an upper case D) from the name element of the XML file? Or is there a way to make the query NOT case sensitive?
Here is the XPath and PHP code:
$xmldoc = simplexml_load_file("products.xml");
$query = $xmldoc->xpath('/products/product[contains(name,"desk")]');
foreach($query as $Products) {
echo $Products->name . " ";
echo $Products->price . "<br>";
}
Here is the XML file (named product.xml):
<products>
<product type="Electronics">
<name>Desktop</name>
<price>499.99</price>
<store>Best Buy</store>
</product>
<product type="Hardware">
<name>Hand Saw</name>
<price>99.99</price>
<store>Lowes</store>
</product>
</products>
Thanks!