I have the following (simplified XML):
<?xml version="1.0" encoding="UTF-8" ?> <products> <product> <artnr>xxx1</artnr> </product> </products>
And the following (again simplified PHP code):
$xml= @simplexml_load_file($filename); foreach ($xml->product as $product) { if (!$this->validate_xml_product($product)) { continue; } } function validate_xml_product($product) { if (!property_exists('artnr', $product)) {
For some reason, the product never checks.
Is property_exists the right way to find out if there is an artnr element in $ product?
source share