Class XML_doc

Simple class for extracting values from a XML document. Uses a simplified XPath syntax to access the elements. For example: 'root/person/name' would return the value of the 'name' node in 'root/person' node. You have to specify the root node name. Can't access node attributes yet.

 Methods

Class Construcor

XML_doc() 

Translate literal entities to their numeric equivalents and vice versa.

_translateLiteral2NumericEntities(string $xmlSource, bool $reverse) : \The

PHP's XML parser (in V 4.1.0) has problems with entities! The only one's that are recognized are &, < > and ". ALL others (like   © a.s.o.) cause an XML_ERROR_UNDEFINED_ENTITY error. I reported this as bug at http://bugs.php.net/bug.php?id=15092 The work around is to translate the entities found in the XML source to their numeric equivalent E.g.   to / © to © a.s.o.

NOTE: Entities &, < > and " are left 'as is'

author Sam Blum bs_php@users.sourceforge.net

Parameters

$xmlSource

string

The XML string

$reverse

bool

(default=FALSE) Translate numeric entities to literal entities.

Returns

\TheXML string with translated entities.

characterData()

characterData($parser, $data) 

Parameters

$parser

$data

endElement()

endElement($parser, $name) 

Parameters

$parser

$name

findLoosePath: Finds a path in the XML array which ends with the given keys

findLoosePath(\aCombination $aCombination, $aScope) : false

Parameters

$aCombination

\aCombination

array of keys to test for

$aScope

Returns

falseif nothing was found, or the array with the found keys

load()

load(string $filename) : boolean

Load the XML file

Parameters

$filename

string

XML document filename

Returns

booleantrue if the load was successful

parse()

parse($send) : array

Parse the xml file in an array

Parameters

$send

Returns

arrayparsearray

startElement()

startElement($parser, $name, $attrs) 

Parameters

$parser

$name

$attrs

valueOf()

valueOf($xpath) : String

Extract one node value from the XML document. Use simplified XPath syntax to specify the node. F.e. 'root/test/firstnode'

Parameters

$xpath

Returns

StringValue of XML node

 Properties

 

XML encoding

$encoding 

 

$errors

$errors : array

 

array

$itemname : \help

 

array

$parsearray : \parsed

 

XML Parser Object

$parser 

 

xml

$xml : string