Jump to content

Passing xml array


ameliabob

Recommended Posts

I have tried to load an xml file using simplexml. I then try to pass the loaded file but it doesn't seem to pass.The code is

<?phpif (file_exists('t.xml'))  {	$xml = simplexml_load_file('t.xml');  }	else {  	echo ('Error.');  	exit('Error.');  }  	function GetXMLfield( $xml, $whichOne){		$tags = $xml->xpath( $whichOne );		return $tags[0];	}		$result = GetXMLfield($xml, "dataType");print($result);//  var_dump($xml);  ?>

The $xml doesn't pass to the GetXMLfield.

Link to comment
Share on other sites

What's in t.xml?Also, keep in mind that XPaths should be absolute, so try

'//dateType'

when calling the function.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...