class XmlValidator (View source)

Class XmlValidator.

Validates XML against XSD

Properties

protected DOMDocument $domDocument

DOM Document.

protected string $xsd

XML Schema Definition.

Methods

__construct()

Constructor.

bool
is_valid(string $xmlStr, bool $ignoreHtml = true)

Check if a string is valid XML.

array
validate(string $xmlStr, string $xsdFilePath, int $flags = 0, bool $checkXml = false)

Validate XML string.

mixed
getElement($message)

Get element from message.

string
getMessage($message)

Get refined message.

Details

__construct()

Constructor.

bool is_valid(string $xmlStr, bool $ignoreHtml = true)

Check if a string is valid XML.

Parameters

string $xmlStr
bool $ignoreHtml

Return Value

bool

See also

https://stackoverflow.com/a/31240779/2732184

array validate(string $xmlStr, string $xsdFilePath, int $flags = 0, bool $checkXml = false)

Validate XML string.

Parameters

string $xmlStr
string $xsdFilePath
int $flags
bool $checkXml

Return Value

array

Exceptions

Exception

See also

https://www.php.net/manual/en/class.simplexmlelement.php#107869

protected mixed getElement($message)

Get element from message.

Parameters

$message

Return Value

mixed

protected string getMessage($message)

Get refined message.

Parameters

$message

Return Value

string