What is the purpose of simplexml_load_file in PHP and how is it used?
The purpose of simplexml_load_file in PHP is to load an XML file and parse it into a SimpleXMLElement object, allowing easy manipulation of XML data. It is commonly used to read XML data from a file and extract specific information for further processing in a PHP script.
// Load an XML file and parse it into a SimpleXMLElement object
$xml = simplexml_load_file('data.xml');
// Access specific elements and attributes from the XML data
echo $xml->book[0]->title;
echo $xml->book[1]['category'];