Possible Duplicate:
SimpleXML Reading node with a hyphenated name
I parse xml file which contain fields like that:
<offers>
<offer>
<type>Vehicle</type>
<type-id>2</type-id>
<category>Car</category>
<category-id>3</category-id>
...
</offer>
<offer>
<type>Vehicle</type>
<type-id>2</type-id>
<category>Car</category>
<category-id>3</category-id>
...
</offer>
...
</offers>
Use $xml = simplexml_load_file($file);
first and after trying to get values in foreach loop I get error "Use of undefined constant id - assumed 'id'" for field contain 'id' as part of them, like 'type-id' or 'category-id'
foreach($xml->offers->offer as $offer) {
echo $offer->type; // WORKS JUST FINE
echo $offer->type-id; //THIS GIVE ME ERROR
}
I trying to set ini_set('error_reporting', E_ALL & ~E_NOTICE);
but after it field with 'id' return zero instead of value.