diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 3a9251f..ff81655 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,3 +1 @@
-# These are supported funding model platforms
-
github: byjg
diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml
index 402fee8..c2f2580 100644
--- a/.github/workflows/phpunit.yml
+++ b/.github/workflows/phpunit.yml
@@ -16,6 +16,7 @@ jobs:
strategy:
matrix:
php-version:
+ - "8.4"
- "8.3"
- "8.2"
- "8.1"
@@ -23,8 +24,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: composer install
- - run: ./vendor/bin/phpunit --stderr
- run: ./vendor/bin/psalm
+ - run: ./vendor/bin/phpunit
Documentation:
if: github.ref == 'refs/heads/master'
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..6bcabfb
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,35 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Debug current Script in Console",
+ "type": "php",
+ "request": "launch",
+ "program": "${file}",
+ "cwd": "${fileDirname}",
+ "port": 9003,
+ "runtimeArgs": [
+ "-dxdebug.start_with_request=yes"
+ ],
+ "env": {
+ "XDEBUG_MODE": "debug,develop",
+ "XDEBUG_CONFIG": "client_port=${port}"
+ }
+ },
+ {
+ "name": "PHPUnit Debug",
+ "type": "php",
+ "request": "launch",
+ "program": "${workspaceFolder}/vendor/bin/phpunit",
+ "cwd": "${workspaceFolder}",
+ "port": 9003,
+ "runtimeArgs": [
+ "-dxdebug.start_with_request=yes"
+ ],
+ "env": {
+ "XDEBUG_MODE": "debug,develop",
+ "XDEBUG_CONFIG": "client_port=${port}"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index b1e2cd1..a9ac0ad 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,95 @@
-# XmlUtil
-
[](https://github.com/byjg/php-xmlutil/actions/workflows/phpunit.yml)
[](http://opensource.byjg.com)
[](https://github.com/byjg/php-xmlutil/)
[](https://opensource.byjg.com/opensource/licensing.html)
[](https://github.com/byjg/php-xmlutil/releases/)
-A utility class to make it easy work with XML in PHP
+# PHP XML Util
+
+A powerful and intuitive PHP library for working with XML documents. This utility makes XML manipulation, querying,
+and conversion simple and straightforward in PHP.
+
+## Overview
+
+PHP XML Util provides a comprehensive set of tools for XML manipulation in PHP applications. It simplifies common
+XML operations with an intuitive API, allowing developers to create, modify, query, and validate XML documents
+with minimal code.
+
+The library is designed to be lightweight yet powerful, offering features that go beyond
+PHP's built-in XML functionality while maintaining a clean and easy-to-use interface.
-## Examples
+## Key Features
-- [Create a new XML Document using the API](docs/using-api.md)
-- [Working with namespaces](docs/namespaces.md)
-- [Query a XMLDocument](docs/query-document.md)
-- [Convert any model to XML](docs/convert-model-xml.md)
-- [Use Attributes to help in the conversion](docs/convert-model-xml-withattributes.md)
-- [Clean an XML document removing specific tags](docs/clean-document.md)
+- **Simple XML Creation API** - Create and manipulate XML documents programmatically with an intuitive API
+- **XPath Querying** - Easily query and navigate XML documents using XPath expressions
+- **PHP Model ↔ XML Conversion** - Seamlessly convert between PHP objects and XML representations
+- **Attribute-Based Mapping** - Use PHP attributes to control XML serialization behavior
+- **Namespace Support** - Full support for XML namespaces in all operations
+- **Document Cleaning** - Selectively remove specific tags from XML documents
+- **XML Validation** - Validate XML documents against schemas
+- **File Handling** - Convenient methods for loading and saving XML from/to files
-## Install
+## Quick Example
+
+```php
+');
+
+// Build the document structure
+$myNode = $xml->appendChild('mynode');
+$myNode->appendChild('subnode', 'text');
+$myNode->appendChild('subnode', 'more text');
+$otherNode = $myNode->appendChild('othersubnode', 'other text');
+$otherNode->addAttribute('attr', 'value');
+
+// Output formatted XML
+echo $xml->toString(format: true);
+```
+
+Output:
+```xml
+
+
+
+ text
+ more text
+ other text
+
+
+```
+
+## Documentation
+
+The library is fully documented with detailed guides and examples for each feature:
+
+- [Creating XML Documents](docs/using-api.md): Learn how to create and manipulate XML documents using the API
+- [Working with Namespaces](docs/namespaces.md): Guide to handling XML namespaces properly
+- [Querying with XPath](docs/query-document.md): How to use XPath expressions to query XML documents
+- [PHP Models to XML](docs/convert-model-xml.md): Converting PHP objects to XML and vice versa
+- [Attribute-Based Mapping](docs/convert-model-xml-withattributes.md): Using PHP attributes to control XML serialization
+- [Cleaning Documents](docs/clean-document.md): Removing specific tags from XML documents
+- [File Operations](docs/file-handling.md): Loading and saving XML from/to files
+- [XML Validation](docs/validate-document.md): Validating XML documents against schemas
+
+## Installation
```bash
composer require "byjg/xmlutil"
```
-## Running the Tests
+## Running Tests
```bash
vendor/bin/phpunit
```
+## License
+
+MIT
+
## Dependencies
```mermaid
@@ -38,6 +99,5 @@ flowchart TD
byjg/xmlutil --> byjg/serializer
```
-
----
[Open source ByJG](http://opensource.byjg.com)
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 6fecd5b..e9d9545 100644
--- a/composer.json
+++ b/composer.json
@@ -14,15 +14,15 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
- "php": ">=8.1 <8.4",
+ "php": ">=8.1 <8.5",
"ext-dom": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
- "byjg/serializer": "^5.0"
+ "byjg/serializer": "^5.1"
},
"require-dev": {
- "phpunit/phpunit": "^9.6",
- "vimeo/psalm": "^5.20"
+ "phpunit/phpunit": "^10.5|^11.5",
+ "vimeo/psalm": "^5.9|^6.2"
},
"license": "MIT"
}
diff --git a/docs/clean-document.md b/docs/clean-document.md
index e85995e..8f07ce4 100644
--- a/docs/clean-document.md
+++ b/docs/clean-document.md
@@ -4,10 +4,9 @@ sidebar_position: 6
# Clean Document
-XmlUtil have a class for selectively remove specific marks (tags)
-from the document or remove all marks.
+XmlUtil provides a dedicated `CleanDocument` class for selectively removing specific tags or content from XML or HTML documents. This is useful for cleaning up documents before processing or display.
-Example:
+## Basic Usage
```php
stripTagsExcept(['img'])
->get();
```
+
+## Available Methods
+
+### stripAllTags()
+
+Removes all HTML/XML tags from the document.
+
+```php
+$document = new \ByJG\XmlUtil\CleanDocument($html);
+$plainText = $document->stripAllTags();
+```
+
+### stripTagsExcept(array $allowedTags)
+
+Strips all HTML/XML tags except those specified in the array.
+
+```php
+$document = new \ByJG\XmlUtil\CleanDocument($html);
+$cleanHtml = $document->stripTagsExcept(['p', 'div', 'span'])->get();
+```
+
+### removeContentByProperty(string $property)
+
+Removes content from any tag that contains the specified property.
+
+```php
+$document = new \ByJG\XmlUtil\CleanDocument($html);
+// Removes all tags containing the "style" property and their content
+$cleanHtml = $document->removeContentByProperty('style')->get();
+```
+
+### removeContentByTag(string $tag, string $property = '')
+
+Removes content from the specified tag, optionally filtering by a property.
+
+```php
+$document = new \ByJG\XmlUtil\CleanDocument($html);
+// Removes all