Xml

XmlNativeParser
in package

A lightweight wrapper around PHP's native XML API.

Table of Contents

Properties

$parser  : XMLParser

Methods

getCaseFolding()  : bool
Retrieve the parser option value of `XML_OPTION_CASE_FOLDING`.
getCurrentByteIndex()  : int
Gets the parser's current byte index in its data buffer.
getCurrentColumn()  : int
Gets the parser's current column number in its data buffer.
getCurrentLine()  : int
Gets the parser's current line number in its data buffer.
getErrorCode()  : ErrorCode
Gets the error code for the last error that occurred.
getOption()  : string|int|bool
Retrieve a parser option.
getSkipTagStart()  : int
Retrieve the parser option value of `XML_OPTION_SKIP_TAGSTART`.
getSkipWsp()  : bool
Retrieve the parser option value of `XML_OPTION_SKIP_WHITE`.
getTargetEncoding()  : Encoding
Retrieve the parser option value of `XML_OPTION_TARGET_ENCODING`.
new()  : self
Create a new `XmlNativeParser` instance, which may use a specific text encoding.
newWithNamespace()  : self
Create a new `XmlNativeParser` instance that supports XML namespaces, which may use a specific text encoding and a separator.
onCharacterData()  : true
Calls a user-defined function when the parser encounters a character data node.
onDefault()  : true
Calls a user-defined function that runs by default in the event-driven parser.
onElement()  : true
Calls a function that will run when the parser encounters an XML element.
onEndNamespaceDecl()  : true
Calls a user-defined function when the parser encounters the end of a namespace declaration.
onExternalEntityRef()  : true
Calls a user-defined function when the parser encounters an external entity reference.
onNotationDecl()  : true
Calls a user-defined function when the parser encounters a notation declaration.
onProcessingInstruction()  : true
Calls a user-defined function when the parser encounters a processing instruction.
onStartNamespaceDecl()  : true
Calls a user-defined function when the parser encounters the start of a namespace declaration.
onUnparsedEntityDecl()  : true
Calls a user-defined function when the parser encounters an unparsed entity declaration.
parse()  : int
Parses an XML document.
parseFinalize()  : int
Finalizes the parsing of an XML document.
parseIntoStruct()  : XmlParseResult|false
Parses an XML document into a typed `XmlParseResult` instance.
setCaseFolding()  : bool
Sets the parser option of `XML_OPTION_CASE_FOLDING`.
setOption()  : bool
Sets a parser option.
setSkipTagStart()  : bool
Sets the parser option of `XML_OPTION_SKIP_TAGSTART`.
setSkipWsp()  : bool
Sets the parser option of `XML_OPTION_SKIP_WHITE`.
setTargetEncoding()  : bool
Sets the parser option of `XML_OPTION_TARGET_ENCODING`.
__construct()  : mixed

Properties

Methods

getCaseFolding()

Retrieve the parser option value of `XML_OPTION_CASE_FOLDING`.

public getCaseFolding() : bool
Return values
bool

getCurrentByteIndex()

Gets the parser's current byte index in its data buffer.

public getCurrentByteIndex() : int

Internally calls xml_get_current_byte_index().

Return values
int

getCurrentColumn()

Gets the parser's current column number in its data buffer.

public getCurrentColumn() : int

Internally calls xml_get_current_column_number().

Return values
int

getCurrentLine()

Gets the parser's current line number in its data buffer.

public getCurrentLine() : int

Internally calls xml_get_current_line_number().

Return values
int

getErrorCode()

Gets the error code for the last error that occurred.

public getErrorCode() : ErrorCode

Internally calls xml_get_error_code().

Return values
ErrorCode

getOption()

Retrieve a parser option.

public getOption(Option $option) : string|int|bool

Internally calls xml_parser_get_option.

Parameters
$option : Option
Return values
string|int|bool

getSkipTagStart()

Retrieve the parser option value of `XML_OPTION_SKIP_TAGSTART`.

public getSkipTagStart() : int
Return values
int

getSkipWsp()

Retrieve the parser option value of `XML_OPTION_SKIP_WHITE`.

public getSkipWsp() : bool
Return values
bool

new()

Create a new `XmlNativeParser` instance, which may use a specific text encoding.

public static new([Encoding|null $encoding = null ]) : self
Parameters
$encoding : Encoding|null = null
Return values
self

newWithNamespace()

Create a new `XmlNativeParser` instance that supports XML namespaces, which may use a specific text encoding and a separator.

public static newWithNamespace([Encoding|null $encoding = null ][, string|null $separator = ':' ]) : self
Parameters
$encoding : Encoding|null = null
$separator : string|null = ':'
Return values
self

onCharacterData()

Calls a user-defined function when the parser encounters a character data node.

public onCharacterData(callable(string): void|null $handler) : true

Internally calls xml_set_character_data_handler().

Parameters
$handler : callable(string): void|null
Return values
true

Always returns true

onDefault()

Calls a user-defined function that runs by default in the event-driven parser.

public onDefault(callable(string): void|null $handler) : true

Internally calls xml_set_default_handler().

Parameters
$handler : callable(string): void|null
Return values
true

Always returns true

onElement()

Calls a function that will run when the parser encounters an XML element.

public onElement(callable(string): void|null $startHandler, callable(string): void|null $endHandler) : true

Internally calls xml_set_element_handler().

Parameters
$startHandler : callable(string): void|null
$endHandler : callable(string): void|null
Return values
true

Always returns true

onEndNamespaceDecl()

Calls a user-defined function when the parser encounters the end of a namespace declaration.

public onEndNamespaceDecl(callable(string): void|null $handler) : true

Internally calls xml_set_end_namespace_decl_handler().

Parameters
$handler : callable(string): void|null
Return values
true

Always returns true

onExternalEntityRef()

Calls a user-defined function when the parser encounters an external entity reference.

public onExternalEntityRef(callable(string): void|null $handler) : true

Internally calls xml_set_external_entity_ref_handler().

Parameters
$handler : callable(string): void|null
Return values
true

Always returns true

onNotationDecl()

Calls a user-defined function when the parser encounters a notation declaration.

public onNotationDecl(callable(string): void|null $handler) : true

Internally calls xml_set_notation_decl_handler().

Parameters
$handler : callable(string): void|null
Return values
true

Always returns true

onProcessingInstruction()

Calls a user-defined function when the parser encounters a processing instruction.

public onProcessingInstruction(callable(string): void|null $handler) : true

Internally calls xml_set_processing_instruction_handler().

Parameters
$handler : callable(string): void|null
Return values
true

Always returns true

onStartNamespaceDecl()

Calls a user-defined function when the parser encounters the start of a namespace declaration.

public onStartNamespaceDecl(callable(string): void|null $handler) : true

Internally calls xml_set_start_namespace_decl_handler().

Parameters
$handler : callable(string): void|null
Return values
true

Always returns true

onUnparsedEntityDecl()

Calls a user-defined function when the parser encounters an unparsed entity declaration.

public onUnparsedEntityDecl(callable(string): void|null $handler) : true

Internally calls xml_set_unparsed_entity_decl_handler().

Parameters
$handler : callable(string): void|null
Return values
true

Always returns true

parse()

Parses an XML document.

public parse(string $data[, bool $isFinal = false ]) : int

Internally calls xml_parse().

Parameters
$data : string

The XML data to parse.

$isFinal : bool = false

Whether this data is the last piece of the document.

Return values
int

Returns 1 on success, 0 on failure.

parseFinalize()

Finalizes the parsing of an XML document.

public parseFinalize() : int

Internally calls xml_parse().

Return values
int

Returns 1 on success, 0 on failure.

parseIntoStruct()

Parses an XML document into a typed `XmlParseResult` instance.

public parseIntoStruct(string $data) : XmlParseResult|false

If the parsing failed, it will return false.

Internally calls xml_parse_into_struct().

Parameters
$data : string
Return values
XmlParseResult|false

setCaseFolding()

Sets the parser option of `XML_OPTION_CASE_FOLDING`.

public setCaseFolding(bool $value) : bool
Parameters
$value : bool
Return values
bool

Returns a boolean for whether or not setting the option was a success.

setOption()

Sets a parser option.

public setOption(Option $option, string|int|bool $value) : bool

Internally calls xml_parser_set_option().

Parameters
$option : Option
$value : string|int|bool
Return values
bool

Returns a boolean for whether or not setting the option was a success.

setSkipTagStart()

Sets the parser option of `XML_OPTION_SKIP_TAGSTART`.

public setSkipTagStart(int $value) : bool
Parameters
$value : int
Return values
bool

Returns a boolean for whether or not setting the option was a success.

setSkipWsp()

Sets the parser option of `XML_OPTION_SKIP_WHITE`.

public setSkipWsp(bool $value) : bool
Parameters
$value : bool
Return values
bool

Returns a boolean for whether or not setting the option was a success.

setTargetEncoding()

Sets the parser option of `XML_OPTION_TARGET_ENCODING`.

public setTargetEncoding(Encoding $encoding) : bool
Parameters
$encoding : Encoding
Return values
bool

Returns a boolean for whether or not setting the option was a success.

__construct()

private __construct(XMLParser $parser) : mixed
Parameters
$parser : XMLParser

        
On this page

Search results