Actions

API16

Difference between revisions of "JFactory/getXML"

From Joomla! Documentation

< API16:JFactory
(New page: ===Description=== Reads a XML file. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {...)
 
m (removing red link to edit, no existant pages)
 
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JFactory/getXML|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JFactory/getXML}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 75: Line 75:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JFactory/getXML|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JFactory/getXML}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 90: Line 90:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 00:06, 13 May 2013

Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Reads a XML file.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

static getXML($data, $isFile=true)
Parameter Name Default Value Description
$data $data Full path and file name.
$isFile true false to load a string.

Returns

mixed on success | false on error.

Defined in

libraries/joomla/factory.php

Importing

jimport( 'joomla.factory' );

Source Body

public static function getXML($data, $isFile = true)
{
        jimport('joomla.utilities.xmlelement');
 
        // Disable libxml errors and allow to fetch error information as needed
        libxml_use_internal_errors(true);
 
        if($isFile)
        {
                // Try to load the xml file
                $xml = simplexml_load_file($data, 'JXMLElement');
        }
        else
        {
                // Try to load the xml string
                $xml = simplexml_load_string($data, 'JXMLElement');
        }
 
        if( ! $xml)
        {
                // There was an error
                JError::raiseWarning(100, JText::_('Failed loading XML file'));
 
                if($isFile)
                {
                        JError::raiseWarning(100, $data);
                }
 
                foreach(libxml_get_errors() as $error)
                {
                        JError::raiseWarning(100, 'XML: '.$error->message);
                }
        }
 
        return $xml ;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />