XMLFormatter
in package
implements
FormatterInterface
XML data formatter
Tags
Table of Contents
Interfaces
- FormatterInterface
- Formatter interface
Methods
- format() : false|string
- Takes the given data and formats it.
- arrayToXML() : void
- A recursive method to convert an array into a valid XML string.
- normalizeXMLTag() : string
- Normalizes tags into the allowed by W3C.
Methods
format()
Takes the given data and formats it.
public
format(array<string|int, mixed>|bool|float|int|object|string|null $data) : false|string
Parameters
- $data : array<string|int, mixed>|bool|float|int|object|string|null
Return values
false|string —(XML string | false)
arrayToXML()
A recursive method to convert an array into a valid XML string.
protected
arrayToXML(array<string|int, mixed> $data, SimpleXMLElement &$output) : void
Written by CodexWorld. Received permission by email on Nov 24, 2016 to use this code.
Parameters
- $data : array<string|int, mixed>
- $output : SimpleXMLElement
Tags
normalizeXMLTag()
Normalizes tags into the allowed by W3C.
protected
normalizeXMLTag(int|string $key) : string
Regex adopted from this StackOverflow answer.
Parameters
- $key : int|string