class vB_XML_Parser

vBulletin XML Parsing Object

This class allows the parsing of an XML document to an array

Traits

Properties

protected integer $error_no Error number (0 for no error)
protected integer $xmldata The actual XML data being processed
protected array $parseddata The final, outputtable data
protected array $stack Intermediate stack value used while parsing.
protected string $cdata Current CData being parsed
protected integer $tag_count Number of tags open currently
boolean $include_first_tag Kludge to include the top level element since this parser was written to not return it and now all of the XML functions assume it to not be there
protected integer $error_code Error code from XML object prior to releases of resources. This needs to be done to avoid a segfault in PHP 4. See Bug#24425
protected integer $error_line Error line number from XML object prior to releases of resources. This needs to be done to avoid a segfault in PHP 4. See Bug#24425
protected bool $legacy_mode Whether to behave in legacy mode for compatibility.
protected string $encoding The encoding of the input xml.
protected string $target_encoding Specified target encoding.
protected bool $ncr_encode Specifies whether to NCR encode multibyte.
protected bool $escape_html Whether to escape html in cdata.

Methods

__sleep()

No description

__wakeup()

No description

static 
getList($xmlArray)

No description

__construct($xml, $path = '', $readencoding = false, $extend_memory = true)

Constructor

mixed
parse(string $encoding = 'ISO-8859-1', bool $emptydata = true)

Parses XML document into an array

boolean
parse_xml()

Handle encoding issues as well as parsing the XML into an array

boolean
legacy_parse_xml()

Handle encoding issues as well as parsing the XML into an array

handle_cdata(resource $parser, string $data)

XML parser callback. Handles CDATA values.

handle_element_start(resource $parser, string $name, array $attribs)

XML parser callback. Handles tag opens.

handle_element_end(resource $parser, string $name)

XML parser callback. Handles tag closes.

mixed
error_string()

Returns parser error string

int
error_line()

Returns parser error line number

int
error_code()

Returns parser error code

int
error_no()

Returns parser error number

add_node(array $children, string $name, string $value)

Adds node with appropriate logic, multiple values get added to array where unique are their own entry

unescape_cdata(string $xml)

Adds node with appropriate logic, multiple values get added to array where unique are their own entry

set_encoding(string $encoding)

Overrides the character encoding for the input XML.

set_target_encoding(string $target_encoding, bool $ncr_encode = false, bool $escape_html = false)

Sets the target charset encoding for the parsed XML.

resolve_target_encoding()

Resolves the target encoding of the output.

string
encode(string $data)

Encodes data to the target encoding.

disable_legacy_mode($disable = true)

Disables legacy mode.

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 168
static getList($xmlArray)

Parameters

$xmlArray

at line 187
__construct($xml, $path = '', $readencoding = false, $extend_memory = true)

Constructor

Parameters

$xml
$path
$readencoding
$extend_memory

at line 235
mixed parse(string $encoding = 'ISO-8859-1', bool $emptydata = true)

Parses XML document into an array

Parameters

string $encoding Encoding of the input XML
bool $emptydata Empty the XML data string after parsing

Return Value

mixed array or false on error

at line 294
boolean parse_xml()

Handle encoding issues as well as parsing the XML into an array

Return Value

boolean Success

at line 360
boolean legacy_parse_xml()

Handle encoding issues as well as parsing the XML into an array

Return Value

boolean Success

at line 454
handle_cdata(resource $parser, string $data)

XML parser callback. Handles CDATA values.

Parameters

resource $parser Parser that called this
string $data The CDATA

at line 466
handle_element_start(resource $parser, string $name, array $attribs)

XML parser callback. Handles tag opens.

Parameters

resource $parser Parser that called this
string $name The name of the tag opened
array $attribs The tag's attributes

at line 487
handle_element_end(resource $parser, string $name)

XML parser callback. Handles tag closes.

Parameters

resource $parser Parser that called this
string $name The name of the tag closed

at line 537
mixed error_string()

Returns parser error string

Return Value

mixed error message

at line 554
int error_line()

Returns parser error line number

Return Value

int error line number

at line 571
int error_code()

Returns parser error code

Return Value

int error line code

at line 588
int error_no()

Returns parser error number

Return Value

int error number

at line 608
add_node(array $children, string $name, string $value)

Adds node with appropriate logic, multiple values get added to array where unique are their own entry

Parameters

array $children Reference to array node has to be added to
string $name Name of node
string $value Value of node

at line 631
unescape_cdata(string $xml)

Adds node with appropriate logic, multiple values get added to array where unique are their own entry

Parameters

string $xml XML to have any of our custom CDATAs to be made into CDATA

at line 655
set_encoding(string $encoding)

Overrides the character encoding for the input XML.

Parameters

string $encoding charset

at line 668
set_target_encoding(string $target_encoding, bool $ncr_encode = false, bool $escape_html = false)

Sets the target charset encoding for the parsed XML.

Parameters

string $target_encoding Target charset
bool $ncr_encode Whether to ncr encode non ASCII
bool $escape_html Whether to escape HTML

at line 679
resolve_target_encoding()

Resolves the target encoding of the output.

at line 701
string encode(string $data)

Encodes data to the target encoding.

Parameters

string $data UTF-8 string to reencode

Return Value

string The reencoded string

at line 733
disable_legacy_mode($disable = true)

Disables legacy mode.

With legacy mode disabled character encoding is handled correctly however legacy dependencies will break.

Parameters

$disable