Sun Jun 28 2020

Read XML File

PHP Scripting2737 views

File Name: 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:
Customer Name: Website

Customer Name: Jonny
Customer Name:
Customer Name: Android App

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