$xml = simplexml_load_file("example.xml"); // Load XML file echo $xml->person[0]->name; // Output first person's name
$xml = simplexml_load_file("example.xml"); // Load XML file $xml->person[0]->name = "John Smith"; // Modify first person's name $xml->asXML("example.xml"); // Save changes back to fileThis code loads an XML file named "example.xml" using the `simplexml_load_file()` function, modifies the name of the first person element, and saves the modified XML back to the file using the `asXML()` function. Again, the code uses the simplexml package library. Overall, the Php Xml element provides a simple and powerful way to work with XML data in PHP applications. It also supports other XML processing libraries like DOM and SAX.