Actions

JFactory/getXMLParser

From Joomla! Documentation

Returns a reference to the global XML parser object, only creating it if it doesn't already exist. The object returned depends on the type of XML parser requested.

Syntax

object getXml(string $xmlfile, boolean $isFile = true)

where:

Argument Data type Description Default
$type string This is the path to the xml file
$boolean boolean Checks if its a file or not true

The currently supported XML parsers are:

$type Parser
rss The SimplePie parser for RSS feeds. The feed URL should be passed in $options['rssUrl']. The cache expiry time may be passed in $options['cache_time'].
atom Synonym for 'rss'.
simple The JSimpleXML parser.
dom The Domit parser. If $options['lite'] is true then the Domit Lite parser will be used instead.

Example

In this example, the JSimpleXML parser is used to retrieve the list of pre-defined module positions from the Joomla 3 Protostar template.

$xmlfile = 'templates/protostar/templateDetails.xml';
$xml = JFactory::getXML( $xmlfile );
 
foreach ($xml->positions->position as $position) {
  echo $position . "<br />";
}

The output will be

banner
debug
position-0
position-1
position-2
position-3
position-4
position-5
position-6
position-7
position-8
position-9
position-10
position-11
position-12
position-13
position-14
footer

See also