Phpfox_Xml_Parser

Description

XML Parser Class is used to convert an XML STRING into a ARRAY.

Sample XML code we are working with:

  1.  <foo var="value">
  2.          <sample extra="info">
  3.              This is some value.
  4.          </sample>
  5.  </foo>

PHP code to parse XML STRING:

  1.  $aXmlData Phpfox::getLib('xml.parser')->parse($sXml);

The variable $aXmlData will output the following array:

  1.  $aXmlData array(
  2.          'foo' => array(
  3.              'var' => 'value',
  4.              'sample' => array(
  5.                  'extra' => 'info',
  6.                  'value' => 'This is some value'
  7.              )
  8.          )
  9.  );

  • author: Raymond Benc
  • version: $Id: parser.class.php 1687 2010-07-22 03:13:27Z Raymond_Benc $
  • copyright: [PHPFOX_COPYRIGHT]

Located in /include/library/phpfox/xml/parser.class.php (line 44)


	
			
Variable Summary
 array $_aData
 array $_aStack
 int $_iError
 int $_iTagCnt
 object $_oXml
 string $_sCdata
 string $_sXml
Method Summary
 Phpfox_Xml_Parser __construct ()
 int errorCode ()
 int errorLine ()
 string errorString ()
 string getXml (string $mFile)
 mixed parse (string $mFile, [string $sEncoding = 'ISO-8859-1'], [bool $bEmptyData = true])
 void _addNode ( &$aChildrens, string $sName, string $sValue, array $aChildrens)
 void _handleCdata ( &$oParser, string $sData, object $oParser)
 void _handleElementEnd ( &$oParser, unknown_type $sName, unknown_type $oParser)
 void _handleElementStart ( &$oParser, string $sName, array $aAttributes, object $oParser)
 string _unescapeCdata (string $sXml)
Variables
array $_aData = array() (line 66)

ARRAY of data we picked up and parsed from the XML string.

  • access: private
array $_aStack = array() (line 80)

Stack XML.

  • access: private
bool $_bIncludeFirstTag = false (line 94)

Check to include the first tag.

  • access: private
int $_iError = 0 (line 73)

Error ID#.

  • access: private
int $_iErrorCode = 0 (line 108)

Error code.

  • access: private
int $_iErrorLine = 0 (line 115)

Error line.

  • access: private
int $_iTagCnt = 0 (line 101)

Total number of tags.

  • access: private
object $_oXml = null (line 52)

XML object.

string $_sCdata (line 87)

CDATA string.

  • access: private
string $_sXml (line 59)

XML string to parse.

  • access: private
Methods
Constructor __construct (line 121)

Class constructor.

  • access: public
Phpfox_Xml_Parser __construct ()
errorCode (line 233)

Error code.

  • access: public
int errorCode ()
errorLine (line 216)

Error line.

  • access: public
int errorLine ()
errorString (line 199)

Error phrase.

  • access: public
string errorString ()
getXml (line 131)

Get the XML content.

  • return: XML data.
  • access: public
string getXml (string $mFile)
  • string $mFile: XML data or XML file.
parse (line 149)

Parse XML code and convert into an ARRAY.

  • return: FALSE if errors were found, ARRAY if no errors and XML was converted into an ARRAY.
  • access: public
mixed parse (string $mFile, [string $sEncoding = 'ISO-8859-1'], [bool $bEmptyData = true])
  • string $mFile: XML data or XML file name.
  • string $sEncoding: Encoding.
  • bool $bEmptyData: TRUE to empty XML data.
_addNode (line 338)

Add children.

  • access: private
void _addNode ( &$aChildrens, string $sName, string $sValue, array $aChildrens)
  • array $aChildrens: Child ARRAY.
  • string $sName: Name of the tag.
  • string $sValue: Value of the tag.
  • &$aChildrens
_handleCdata (line 251)

Handle CDATA by storing it in a variable.

  • access: private
void _handleCdata ( &$oParser, string $sData, object $oParser)
  • object $oParser: Object parser.
  • string $sData: CDATA string we parsed.
  • &$oParser
_handleElementEnd (line 288)

Handle the end of an element.

  • access: private
void _handleElementEnd ( &$oParser, unknown_type $sName, unknown_type $oParser)
  • unknown_type $oParser: Object parser.
  • unknown_type $sName: Name of the element.
  • &$oParser
_handleElementStart (line 263)

Handle the start of an element.

  • access: private
void _handleElementStart ( &$oParser, string $sName, array $aAttributes, object $oParser)
  • object $oParser: Object parser.
  • string $sName: Name of the element.
  • array $aAttributes: List of attributes.
  • &$oParser
_unescapeCdata (line 361)

Unescape CDATA.

  • return: Converted XML unescaped CDATA.
  • access: private
string _unescapeCdata (string $sXml)
  • string $sXml: XML code to parse.

Documentation generated on Tue, 28 Sep 2010 10:36:42 +0200 by phpDocumentor 1.4.0a2