elements from a xml file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
adicooldude
New php-forum User
New php-forum User
Posts: 10
Joined: Mon Apr 07, 2014 2:26 am

Re: elements from a xml file

Post by adicooldude » Mon Apr 07, 2014 2:34 am

Hi,
try this

Code: Select all

if (file_exists('sample.xml')) {
	# The XML file with bad characters
	$filename = "sample.xml";
	
	# Read file contents to a variable
	$contents = file_get_contents($filename);
	try{
		$xml_response = new SimpleXmlElement($contents, LIBXML_NOCDATA);
		echo ($xml_response->server_ip)."\n";
		echo ($xml_response->domain)."\n";
		echo ($xml_response->license_key)."\n";
		echo ($xml_response->allowed)."\n";
		echo ($xml_response->used)."\n";
		echo ($xml_response->expire)."\n";
		echo ($xml_response->update)."\n";
		echo ($xml_response->check)."\n";
	}catch (Exception $e){
		echo $e;
	}
	
}

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests