XMLFormatter
in package
implements
FormatterInterface
XML data formatter
Interfaces, Classes and Traits
- FormatterInterface
- Formatter interface
Table of Contents
- format() : string|bool
- Takes the given data and formats it.
- arrayToXML() : mixed
- 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(mixed $data) : string|bool
Parameters
- $data : mixed
Return values
string|bool —(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) : mixed
Written by CodexWorld. Received permission by email on Nov 24, 2016 to use this code.
Parameters
- $data : array<string|int, mixed>
- $output : SimpleXMLElement
Tags
Return values
mixed —normalizeXMLTag()
Normalizes tags into the allowed by W3C.
protected
normalizeXMLTag(string|int $key) : string
Regex adopted from this StackOverflow answer.
Parameters
- $key : string|int