-
Notifications
You must be signed in to change notification settings - Fork 4
Class XmlDocumentWriter
Class representing the XML writer helper
Constructor
public function __construct(string $tag, string $version = '1.0', string $encoding = 'UTF-8'): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
tag | string | ❌ |
Specify the root tag of the document |
version | string | ❌ | |
encoding | string | ❌ |
Returns a value of type \XmlDocumentWriter
Add a namespace declaration to the root
public function addNamespace(string $namespace, string $value): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
namespace | string | ❌ | |
value | string | ❌ |
Returns a value of type \XmlDocumentWriter
Start an element
public function startElement(string $tag, string $value = ''): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
tag | string | ❌ | |
value | string | ❌ |
Returns a value of type \XmlDocumentWriter
End an element
public function endElement(): \XmlDocumentWriter
{
}
Returns a value of type \XmlDocumentWriter
Write a single element
public function element(string $tag, ?string $value = ''): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
tag | string | ❌ | |
value | string | ✔️ |
Returns a value of type \XmlDocumentWriter
Write a single element if $condition is true
public function elementIf(bool $condition, string $tag, ?string $value = ''): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
condition | bool | ❌ | |
tag | string | ❌ | |
value | string | ✔️ |
Returns a value of type \XmlDocumentWriter
Write a single element with a single attribute
public function elementWithAttribute(
string $tag,
?string $value = '',
?string $attributeName = '',
?string $attributeValue = '',
): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
tag | string | ❌ | |
value | string | ✔️ | |
attributeName | string | ✔️ | |
attributeValue | string | ✔️ |
Returns a value of type \XmlDocumentWriter
Write a single element with multiple attributes
public function elementWithMultipleAttributes(
string $tag,
?string $value = '',
array $attributes = [],
): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
tag | string | ❌ | |
value | string | ✔️ | |
attributes | array | ❌ |
Returns a value of type \XmlDocumentWriter
Add an attribute to latest element when value is given
public function attribute(string $name, ?string $value = null): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
name | string | ❌ | |
value | string | ✔️ |
Returns a value of type \XmlDocumentWriter
Change the root of the document
public function changeRoot(string $newRoot): \XmlDocumentWriter
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
newRoot | string | ❌ |
Returns a value of type \XmlDocumentWriter
Start a group
public function group(string $tagName, mixed $callback): void
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
tagName | string | ❌ | |
callback | mixed | ❌ |
Get XML as a string
public function saveXmlString(): string
{
}
Returns a value of type string
Save XML to file
public function saveXmlFile(string $filename): int|false
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
filename | string | ❌ |
Returns a value of type int|false
(c) HorstOeko 2024..