Xml
class Xml (View source)
Constants
FLAG_PRESERVE_CARRIAGE_RETURNS |
|
Methods
Extract a boolean from an element or an attribute value.
Create a new element with the specified value.
Append a new CDATA section to an existing element.
Using a CDATA section is not mandatory: it'd be enough to call htmlentities(..., ENT_XML1).
Details
bool|null
getBool(SimpleXMLElement|null $elementOrAttribute, bool|null $default = false)
Extract a boolean from an element or an attribute value.
SimpleXMLElement
createChildElement(SimpleXMLElement $parentElement, string $childName, scalar|DateTimeInterface|Stringable $value, int $flags = 0)
Create a new element with the specified value.
void
appendCData(SimpleXMLElement $element, string $value)
Append a new CDATA section to an existing element.
Please remark that \r\n and \r sequences will be converted to \n - see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-line-ends
createCDataNode(SimpleXMLElement $x, $nodeName, $content)
deprecated
deprecated
No description
protected string
serialize(scalar|DateTimeInterface|Stringable $value)
No description
protected bool
shouldUseCData(string $value)
Using a CDATA section is not mandatory: it'd be enough to call htmlentities(..., ENT_XML1).
But CDATA is much more readable, so let's use it when values contains characters that must be escaped).