Skip to content

Class XmlDocumentReader

HorstOeko edited this page Dec 21, 2024 · 2 revisions

Summary

Class representing the XML reader helper

Methods

__construct

Summary

Constructor

Signature

public function __construct(): \XmlDocumentReader
{
}

Returns

Returns a value of type \XmlDocumentReader

addNamespace

Summary

Add a namespace declaration to the root

Signature

public function addNamespace(string $namespace, string $value): static
{
}

Parameters

Name Type Allows Null Description
namespace string
value string

Returns

Returns a value of type static

loadFromXmlString

Summary

Load from XML string

Signature

public function loadFromXmlString(string $source): \XmlDocumentReader
{
}

Parameters

Name Type Allows Null Description
source string

Returns

Returns a value of type \XmlDocumentReader

loadFromXmlFile

Summary

Load from XML file

Signature

public function loadFromXmlFile(string $filename): \XmlDocumentReader
{
}

Parameters

Name Type Allows Null Description
filename string

Returns

Returns a value of type \XmlDocumentReader

exists

Summary

Returns true if the expression found anything

Signature

public function exists(string $expression, ?DOMNode $contextNode = null): bool
{
}

Parameters

Name Type Allows Null Description
expression string
contextNode DOMNode ✔️

Returns

Returns a value of type bool

query

Summary

Executes the given XPath expression.

Signature

public function query(string $expression, ?DOMNode $contextNode = null): \DOMNodeList|false
{
}

Parameters

Name Type Allows Null Description
expression string
contextNode DOMNode ✔️

Returns

Returns a value of type \DOMNodeList|false

queryValue

Summary

Returns the value of a query

Signature

public function queryValue(string $expression, ?DOMNode $contextNode = null): string|null
{
}

Parameters

Name Type Allows Null Description
expression string
contextNode DOMNode ✔️

Returns

Returns a value of type string|null

queryAll

Summary

Returns the value of a query

Signature

public function queryAll(string $expression, ?DOMNode $contextNode = null): void
{
}

Parameters

Name Type Allows Null Description
expression string
contextNode DOMNode ✔️

whenExists

Summary

When an element can be queried the $callback is called otherwise $callbackElse

Signature

public function whenExists(
  string $expression,
  ?DOMNode $contextNode,
  mixed $callback,
  mixed $callbackElse = null,
): \XmlDocumentReader
{
}

Parameters

Name Type Allows Null Description
expression string
contextNode DOMNode ✔️
callback mixed
callbackElse mixed

Returns

Returns a value of type \XmlDocumentReader

whenNotExists

Summary

When an element cannot be queried the $callback is called otherwise $callbackElse

Signature

public function whenNotExists(
  string $expression,
  ?DOMNode $contextNode,
  mixed $callback,
  mixed $callbackElse = null,
): \XmlDocumentReader
{
}

Parameters

Name Type Allows Null Description
expression string
contextNode DOMNode ✔️
callback mixed
callbackElse mixed

Returns

Returns a value of type \XmlDocumentReader

whenEquals

Summary

When an element equals value(s) the $callback is called

Signature

public function whenEquals(
  string $expression,
  ?DOMNode $contextNode,
  mixed $values,
  mixed $callback,
  mixed $callbackElse = null,
): \XmlDocumentReader
{
}

Parameters

Name Type Allows Null Description
expression string
contextNode DOMNode ✔️
values mixed
callback mixed
callbackElse mixed

Returns

Returns a value of type \XmlDocumentReader

whenNotEquals

Summary

When an element not equals value(s) the $callback is called

Signature

public function whenNotEquals(
  string $expression,
  ?DOMNode $contextNode,
  mixed $values,
  mixed $callback,
  mixed $callbackElse = null,
): \XmlDocumentReader
{
}

Parameters

Name Type Allows Null Description
expression string
contextNode DOMNode ✔️
values mixed
callback mixed
callbackElse mixed

Returns

Returns a value of type \XmlDocumentReader

whenOneExists

Summary

When one exists

Signature

public function whenOneExists(
  array $expressions,
  array $contextNodes,
  mixed $callback,
  mixed $callbackElse = null,
): \XmlDocumentReader
{
}

Parameters

Name Type Allows Null Description
expressions array
contextNodes array
callback mixed
callbackElse mixed

Returns

Returns a value of type \XmlDocumentReader