class LaravelXml (View source)

Methods

__construct()

No description

string
encode(string[] $arr, string $rootElementName = 'document', bool $replaceSpacesByUnderScoresInKeyNames = true, string $xmlEncoding = 'UTF-8', string $xmlVersion = '1.0')

Convert the an array to an xml string.

mixed
decode(string $data, string $class_name = 'SimpleXMLElement', int $options = 0, string $ns = '', bool $is_prefix = false)

Convert a string of XML into an array.

bool
is_valid(string $xmlStr, bool $ignoreHtml = true)

Check if a string is valid XML.

array
validate(string $xmlStr, string $xsdFilePath, int $flags = 0, bool $checkXml = false)

Validate XML string.

Details

__construct()

No description

string encode(string[] $arr, string $rootElementName = 'document', bool $replaceSpacesByUnderScoresInKeyNames = true, string $xmlEncoding = 'UTF-8', string $xmlVersion = '1.0')

Convert the an array to an xml string.

Parameters

string[] $arr
string $rootElementName
bool $replaceSpacesByUnderScoresInKeyNames
string $xmlEncoding
string $xmlVersion

Return Value

string

mixed decode(string $data, string $class_name = 'SimpleXMLElement', int $options = 0, string $ns = '', bool $is_prefix = false)

Convert a string of XML into an array.

Parameters

string $data

A well-formed XML string

string $class_name

Default: SimpleXMLElement

int $options
string $ns

Namespace prefix or URI

bool $is_prefix

TRUE if ns is a prefix, FALSE if it's a URI, defaults to FALSE

Return Value

mixed

Array or FALSE on failure

See also

http://php.net/manual/en/function.simplexml-load-string.php
https://stackoverflow.com/a/20431742/2732184
https://stackoverflow.com/a/2970701/2732184

bool is_valid(string $xmlStr, bool $ignoreHtml = true)

Check if a string is valid XML.

Parameters

string $xmlStr
bool $ignoreHtml

Return Value

bool

array validate(string $xmlStr, string $xsdFilePath, int $flags = 0, bool $checkXml = false)

Validate XML string.

Parameters

string $xmlStr
string $xsdFilePath
int $flags
bool $checkXml

Return Value

array Rrrors