ameliabob Posted September 12, 2008 Share Posted September 12, 2008 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 More sharing options...
boen_robot Posted September 13, 2008 Share Posted September 13, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.