If you are not sure which XML APIs might be available : get_declared_classes « Reflection « PHP






If you are not sure which XML APIs might be available

 
<?
$xmlfile = 'myfile.xml'; 
$classes = get_declared_classes(); 

if( in_array('SimpleXMLElement', $classes) ) { 
    $xmldoc = simplexml_load_file($xmlfile); 

} elseif( in_array('DOMDocument', $classes) ) 
{ 
    $xmldoc = new DOMDocument(); 
    $xmldoc->load($xmlfile); 

} else { 
}
?>
  
  








Related examples in the same category

1.get_declared_classes() function returns an array of all defined classes.