CRM_Utils_XML
in package
Tags
Table of Contents
Methods
- filterMarkupText() : string
- Apply a filter to the textual parts of the markup.
- parseFile() : array<string|int, mixed>
- Read a well-formed XML file
- parseString() : array<string|int, mixed>
- Read a well-formed XML file
- xmlObjToArray() : array<string|int, mixed>
- Convert an XML element to an array.
- formatErrors() : string
- tokenizeMarkupText() : array<string|int, mixed>
- Split marked-up text into markup and text.
Methods
filterMarkupText()
Apply a filter to the textual parts of the markup.
public
static filterMarkupText(string $markup, callable $filter) : string
Parameters
- $markup : string
-
Ex: 'Hello world & universe'
- $filter : callable
-
Ex: 'mb_strtoupper'
Return values
string —Ex: 'HELLO WORLD & UNIVERSE'
parseFile()
Read a well-formed XML file
public
static parseFile(string $file) : array<string|int, mixed>
Parameters
- $file : string
Return values
array<string|int, mixed> —(0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE)
parseString()
Read a well-formed XML file
public
static parseString(mixed $string) : array<string|int, mixed>
Parameters
- $string : mixed
Return values
array<string|int, mixed> —(0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE)
xmlObjToArray()
Convert an XML element to an array.
public
static xmlObjToArray(mixed $obj) : array<string|int, mixed>
Parameters
- $obj : mixed
-
SimpleXMLElement.
Return values
array<string|int, mixed>formatErrors()
protected
static formatErrors(mixed $errors) : string
Parameters
- $errors : mixed
Return values
stringtokenizeMarkupText()
Split marked-up text into markup and text.
protected
static tokenizeMarkupText(string $markup) : array<string|int, mixed>
Parameters
- $markup : string
-
Ex: 'link'
Return values
array<string|int, mixed> —Ex: [ ['node', ''], ['text', 'link'], ['node', ''], ]