VerySimpleXmlUtil provides a collection of static methods that are useful when dealing with XML

package verysimple::XML
author VerySimple Inc.
copyright 1997-2007 VerySimple, Inc.
license LGPL
version 3.2

 Methods

Given an XMLReader, returns an object that can be inspected using print_r

ConvertReader(XMLReader $xml) : object

Parameters

$xml

XMLReader

Returns

object

Escapes special characters that will corrupt XML

Escape(String $str, bool $escapeQuotes) 

Parameters

$str

String

to be escaped

$escapeQuotes

bool

(default false) true if you are escaping an attribute (ie )

For a node that is known to have inner text and no other child nodes, this returns the inner text and advances the reader curser to the next element. If there is no text, the curser is not advanced

GetInnerText(XMLReader $xml, string $default) : string

Parameters

$xml

XMLReader

$default

string

(optional) if the value is blank

Returns

string

Handler for catching ParseException errors

HandleParseException($code, $string, $file, $line, $context) 

Parameters

$code

$string

$file

$line

$context

This is method RecurseXmlObjToArr

RecurseXmlObjToArr(mixed $obj, mixed $arr) : mixed

Parameters

$obj

mixed

This is a description

$arr

mixed

This is a description

Returns

mixedThis is the return value description

Parses the given XML using SimpleXMLElement, however traps PHP errors and warnings and converts them to an Exception that you can catch. Surround this statement with try/catch and you can handle parsing exceptions instead of allowing PHP to terminate or write errors to the browser

SafeParse(\$xml $xml) : \SimpleXMLElement

Parameters

$xml

\$xml

string

Returns

converts a string containing xml into an array

ToArray(string $xmlstring, bool $recurse) : array

Parameters

$xmlstring

string

to be unescaped

$recurse

bool

(default false) true to recurse

Returns

array

Recurses value and serializes it as an XML string

ToXML(\variant $var, string $root) : string

Parameters

$var

\variant

object, array or value to convert

$root

string

name of the root node (optional)

Returns

stringXML

UnEscapes special characters from XML that were Escaped

UnEscape(string $str) : string

Parameters

$str

string

to be unescaped

Returns

string

 Properties

 

$replacementsAttrib

$replacementsAttrib 

 

$replacementsTempAttrib

$replacementsTempAttrib 

 

$replacementsTempText

$replacementsTempText 

 

$replacementsText

$replacementsText 

 

$reservedAttrib

$reservedAttrib 

 

$reservedText

$reservedText