PHPackages                             novomirskoy/xml-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. novomirskoy/xml-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

novomirskoy/xml-validator
=========================

0.0.2(2mo ago)00proprietaryPHPPHP ^8.5

Since May 12Pushed 2mo agoCompare

[ Source](https://github.com/novomirskoy/xml-validator)[ Packagist](https://packagist.org/packages/novomirskoy/xml-validator)[ RSS](/packages/novomirskoy-xml-validator/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Xml validator
=============

[](#xml-validator)

XML document validation using XSD schemas

Installation
------------

[](#installation)

Install the library using Composer:

```
composer require novomirskoy/xml-validator
```

### Requirements

[](#requirements)

The following PHP extensions are required for the library to work:

- `ext-dom`
- `ext-libxml`

Usage
-----

[](#usage)

Create an instance of the `Validator` class and call the `validate()` method, passing an XML document as a string and a schema. The schema can be either a **string** or a **path to an XSD file**. Create a schema instance using the named constructors `Schema::file()`or `Schema::string()`, passing the file path or schema string respectively.

The validator does not store the validation result, so it immediately returns a Result object that indicates whether the validation was successful and returns a list of all errors that occurred.

Examples
--------

[](#examples)

```
// Example XML document
$xml =
