{"id":24016349,"url":"https://github.com/decodelabs/exemplar","last_synced_at":"2025-04-15T14:07:31.179Z","repository":{"id":56964662,"uuid":"353358613","full_name":"decodelabs/exemplar","owner":"decodelabs","description":"Powerful XML tools for PHP","archived":false,"fork":false,"pushed_at":"2025-04-14T08:47:08.000Z","size":126,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-15T14:07:09.967Z","etag":null,"topics":["php","xml"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/decodelabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-31T13:01:32.000Z","updated_at":"2025-04-14T08:47:11.000Z","dependencies_parsed_at":"2023-12-06T23:31:34.924Z","dependency_job_id":"6879a62d-08c3-46ad-8c9d-88300b630be8","html_url":"https://github.com/decodelabs/exemplar","commit_stats":{"total_commits":43,"total_committers":1,"mean_commits":43.0,"dds":0.0,"last_synced_commit":"45365eb9ae66c89a8c6e9c6fbe27a7010f43ff32"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fexemplar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fexemplar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fexemplar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fexemplar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decodelabs","download_url":"https://codeload.github.com/decodelabs/exemplar/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085438,"owners_count":21210267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","xml"],"created_at":"2025-01-08T08:49:01.584Z","updated_at":"2025-04-15T14:07:31.170Z","avatar_url":"https://github.com/decodelabs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Exemplar\n\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/exemplar?style=flat)](https://packagist.org/packages/decodelabs/exemplar)\n[![Latest Version](https://img.shields.io/packagist/v/decodelabs/exemplar.svg?style=flat)](https://packagist.org/packages/decodelabs/exemplar)\n[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/exemplar.svg?style=flat)](https://packagist.org/packages/decodelabs/exemplar)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/exemplar/integrate.yml?branch=develop)](https://github.com/decodelabs/exemplar/actions/workflows/integrate.yml)\n[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true\u0026style=flat)](https://github.com/phpstan/phpstan)\n[![License](https://img.shields.io/packagist/l/decodelabs/exemplar?style=flat)](https://packagist.org/packages/decodelabs/exemplar)\n\n### Powerful XML tools for PHP.\n\nExemplar provides a set of exhaustive and intuitive interfaces for reading, writing and manipulating XML documents and fragments.\n\n---\n\n\n## Installation\n\n```bash\ncomposer require decodelabs/exemplar\n```\n\n## Usage\n\n### Reading \u0026 manipulating\n\nAccess and manipulate XML files with a consolidated interface wrapping the DOM functionality available in PHP:\n\n```php\nuse DecodeLabs\\Exemplar\\Element as XmlElement;\n\n$element = XmlElement::fromFile('/path/to/my/file.xml');\n\nif($element-\u003ehasAttribute('old')) {\n    $element-\u003eremoveAttribute('old');\n}\n\n$element-\u003esetAttribute('new', 'value');\n\nforeach($element-\u003escanChildrenOfType('section') as $sectTag) {\n    $inner = $sectTag-\u003egetFirstChildOfType('title');\n    $sectTag-\u003eremoveChild($inner);\n\n    // Flatten to plain text\n    echo $sectTag-\u003egetComposedTextContent();\n}\n\nfile_put_contents('newfile.xml', (string)$element);\n```\n\nSee [Element.php](./src/Element.php) for the full interface.\n\n\n### Writing\n\nProgramatically generate XML output with a full-featured wrapper around PHP's XML Writer:\n\n```php\nuse DecodeLabs\\Exemplar\\Writer as XmlWriter;\n\n$writer = new XmlWriter();\n$writer-\u003ewriteHeader();\n\n$writer-\u003e{'ns:section[ns:attr1=value].test'}(function ($writer) {\n    $writer-\u003e{'title#main'}('This is a title');\n\n    $writer-\u003e{'@body'}('This is an element with content wrapped in CDATA tags.');\n    $writer-\u003ewriteCData('This is plain CDATA');\n});\n\necho $writer;\n```\n\nThis creates:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cns:section ns:attr1=\"value\" class=\"test\"\u003e\n    \u003ctitle id=\"main\"\u003eThis is a title\u003c/title\u003e\n    \u003cbody\u003e\u003c![CDATA[This is an element with content wrapped in CDATA tags.]]\u003e\u003c/body\u003e\n\u003c![CDATA[This is plain CDATA]]\u003e\u003c/ns:section\u003e\n```\n\nSee [Writer.php](./src/Writer.php) for the full interface.\n\n\n## Licensing\nExemplar is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Fexemplar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecodelabs%2Fexemplar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Fexemplar/lists"}