php - XPath - text from elements turned to lowercase -
this xpath/php code checks see if text in of "name" elements in xml file contain string "desk". there way turn text retrieved "name" elements lowercase letters? (ie turn desktop desktop?).
here xpath & php code:
$xmldoc = simplexml_load_file("products.xml"); $query = $xmldoc->xpath('/products/product[contains(name,"desk")]'); foreach($query $products) { echo $products->name . " "; echo $products->price . "<br>"; }
here 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>
use strtolower ( string $str )
echo strtolower($products->name) . " "; echo strtolower($products->price) . "<br>";
Comments
Post a Comment