Read XML File

<?php
	/*  Interprets an XML file into an object */
	$xml = simplexml_load_file('customers.xml');
	
	/* Runs XPath query on XML data */
	foreach($xml->xpath("customer") as $customer) {
		
		/* Print XML data */
		echo "Customer Name: ".$customer->name."<br />";
		echo "Customer Name: ".$customer->email."<br />";
		echo "Customer Name: ".$customer->requirement."<br /><br />";
	}
?>



/* Output */
Customer Name: James
Customer Name: [email protected]
Customer Name: Website

Customer Name: Jonny
Customer Name: [email protected]
Customer Name: Android App

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!