I’ve tried looking for an answer in other places but the documentation on XMLParser in Joomla is really poor. Basically, I’m just trying to extract data from nodes in a XML file. If anyone could explain to me what is wrong with my syntax I would appreciate it:
$path = "uploaded_xmls/" . $_FILES["file"]["name"];
$xml =& JFactory::getXMLParser('Simple');
$user = & JFactory::getUser();
if($user->id && $xml->loadFile($path)) {
foreach( $xml->document->track as $track ) {
$track_id = $track->getElementByPath('id');
$track_type = 's';
}
}
JFactory::getXMLParser('simple')returns aaccording to the doc block.
I can’t tell from your code snippet what is going wrong (and you haven’t actually specified), so it could even be an issue for the format of the XML file.
You would probably be better off using
JFactory::getXML($data, $isFile)which is just simplexml_load_XXXX in a wrapper. ie.$datacan be either your XML or a path to the XML file and you set the boolean$isFileaccordingly.The biggest advantage, of course, is that simplexml has plenty documentation and examples/