Actions

JFactory/getXMLParser

From Joomla! Documentation

Revision as of 14:56, 23 November 2008 by Chris Davenport (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 getXMLParser( $$type, $options )

where:

Argument Data type Description Default
$type string Type of XML parser required (not case-sensitive). See below for a list of currently supported options. 'DOM'
$options array Array of options to help specify and configure the XML parser. Depends on the parser selected. array()

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 Milky Way template.

$xml =& JFactory::getXMLParser( 'simple' );
 
$xml->loadFile( 'templates/rhuk_milkyway/templateDetails.xml' );
$positions =& $xml->document->getElementByPath( 'positions' );
foreach ($positions->children() as $position) {
  echo $position->data() . "\n";
}

The output will be

breadcrumb
left
right
top
user1
user2
user3
user4
footer
debug
syndicate

See also