{"id":13828576,"url":"https://github.com/ThomasWeinert/FluentDOM","last_synced_at":"2025-07-09T06:32:13.974Z","repository":{"id":53724950,"uuid":"695660","full_name":"ThomasWeinert/FluentDOM","owner":"ThomasWeinert","description":"A fluent api for working with XML in PHP","archived":false,"fork":false,"pushed_at":"2023-10-22T17:00:19.000Z","size":49248,"stargazers_count":338,"open_issues_count":10,"forks_count":20,"subscribers_count":16,"default_branch":"main","last_synced_at":"2024-11-07T12:16:47.996Z","etag":null,"topics":["dom","fluentdom","jquery-api","php","xml","xmlreader","xmlwriter","xpath"],"latest_commit_sha":null,"homepage":"https://thomas.weinert.info/FluentDOM/","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/ThomasWeinert.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"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":"2010-05-31T15:58:46.000Z","updated_at":"2024-09-15T12:54:12.000Z","dependencies_parsed_at":"2024-06-18T12:29:23.811Z","dependency_job_id":"c1e8dc4a-8391-4d2c-a595-c4abdac3555f","html_url":"https://github.com/ThomasWeinert/FluentDOM","commit_stats":{"total_commits":1576,"total_committers":13,"mean_commits":"121.23076923076923","dds":"0.23794416243654826","last_synced_commit":"22ee56352bb5fd0bc41ccf7906780aabc2bccf33"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasWeinert%2FFluentDOM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasWeinert%2FFluentDOM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasWeinert%2FFluentDOM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasWeinert%2FFluentDOM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThomasWeinert","download_url":"https://codeload.github.com/ThomasWeinert/FluentDOM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225492420,"owners_count":17482869,"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":["dom","fluentdom","jquery-api","php","xml","xmlreader","xmlwriter","xpath"],"created_at":"2024-08-04T09:02:53.104Z","updated_at":"2024-11-20T08:30:47.790Z","avatar_url":"https://github.com/ThomasWeinert.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# FluentDOM\n\n[![CI](https://github.com/ThomasWeinert/FluentDOM/actions/workflows/ci.yml/badge.svg)](https://github.com/ThomasWeinert/FluentDOM/actions/workflows/ci.yml)\n\n[comment]: \u003c\u003e ([![Code Coverage]\u0026#40;https://img.shields.io/scrutinizer/coverage/g/fluentdom/fluentdom.svg\u0026#41;]\u0026#40;https://scrutinizer-ci.com/g/FluentDOM/FluentDOM/?branch=master\u0026#41;)\n[comment]: \u003c\u003e ([![Scrutinizer Code Quality]\u0026#40;https://img.shields.io/scrutinizer/g/fluentdom/fluentdom.svg\u0026#41;]\u0026#40;https://scrutinizer-ci.com/g/FluentDOM/FluentDOM/?branch=master\u0026#41;)\n\n[![License](https://img.shields.io/packagist/l/fluentdom/fluentdom.svg)](http://opensource.org/licenses/mit-license.php)\n[![Total Downloads](https://img.shields.io/packagist/dt/fluentdom/fluentdom.svg)](https://packagist.org/packages/fluentdom/fluentdom)\n[![Latest Stable Version](https://img.shields.io/packagist/v/fluentdom/fluentdom.svg)](https://packagist.org/packages/fluentdom/fluentdom)\n[![Latest Unstable Version](https://img.shields.io/packagist/vpre/fluentdom/fluentdom.svg)](https://packagist.org/packages/fluentdom/fluentdom)\n\nCopyright: 2009-2018 [FluentDOM Contributors](https://github.com/ThomasWeinert/FluentDOM/graphs/contributors)\u003cbr /\u003e\nLicense: [The MIT License](http://www.opensource.org/licenses/mit-license.php) \u003cbr /\u003e\n\nFluentDOM provides extended XML handling classes for PHPs DOM, XMLReader and XMLWriter.\nAdditionally, it contains a easy to use jQuery like, fluent interface for DOM.\n\nHere are loaders and serializers for different formats like JSON, YAML, JsonML and others.\nMore (like HTML5) can be installed as additional packages.\n\nFluentDOM is a test driven project. We write tests before and during the\ndevelopment. You will find the PHPUnit tests in the `tests/` subdirectory.\n\n## Table Of Contents\n* Examples\n* Support\n* Requirements\n* Packagist\n* Usage\n* Backwards Compatibility Breaks\n\n## Examples\n\nMany examples can be found in the `examples/` subdirectory. Here are\nsome for an initial impression:\n\n### Read All Links in a HTML File\n\n```php\n$document = FluentDOM::load(\n  $htmlFile,\n  'text/html',\n  [FluentDOM\\Loader\\Options::ALLOW_FILE =\u003e TRUE]\n);\nforeach ($document('//a[@href]') as $a) {\n  $links[] = [\n    'caption' =\u003e (string)$a,\n    'href' =\u003e $a['href']\n  ];\n}\nvar_dump($links);\n```\n\n### Create a Select From an Array\n\n```php\n$_ = FluentDOM::create();\n$_-\u003eformatOutput = TRUE;\necho $_(\n  'select',\n  ['name' =\u003e 'example'],\n  $_-\u003eeach(\n    ['One', 'Two', 'Three'],\n    function($text, $index) use ($_) {\n      return $_('option', ['value' =\u003e $index], $text);\n    }\n  )\n)-\u003edocument-\u003esaveHTML();\n```\n\n### Read Large XML Files (FluentDOM 6.2)\n\n```php\n$reader = new FluentDOM\\XMLReader();\n$reader-\u003eopen('sitemap.xml');\n$reader-\u003eregisterNamespace('s', 'http://www.sitemaps.org/schemas/sitemap/0.9');\n\nforeach (new FluentDOM\\XMLReader\\SiblingIterator($reader, 's:url') as $url) {\n  /** @var FluentDOM\\DOM\\Element $url */\n  var_dump(\n    [\n      'location' =\u003e $url('string(s:loc)'),\n      'updated' =\u003e $url('string(s:lastmod)')\n    ]\n  );\n}\n```\n\n## Support\n\nThe [wiki](https://github.com/ThomasWeinert/FluentDOM/wiki) provides information and usage examples.\n\nIf you find a bug or have a feature request please report it in the [issue tracker](https://github.com/ThomasWeinert/FluentDOM/issues).\n\nYou can check out the [![Gitter chat](https://img.shields.io/badge/gitter-join--chat-blue.svg)](https://gitter.im/ThomasWeinert/FluentDOM), too.\n\nBe ware that the release packages (downloads) do not include the examples or tests. They are not needed\nto use the library. If you clone the repository, they will be included.\n\n\n### Security Issues\n\nIf you find a bug that has security implications, you can send an email directly to `thomas@weinert.info`.\n\n## Requirements\n\n### PHP\n\n * PHP \u003e= 7.0\n * ext/dom\n * Optional\n    * ext/xmlreader\n    * ext/xmlwriter\n\nFluentDOM needs at least PHP 7.0 and the DOM extension. For some features\nadditional extensions might be needed, like ext/json to load JSON strings.\n\nTo use the extended XMLReader/XMLWriter you will need the respective PHP extensions,\nof course.\n\n### HHVM\n\nFluentDOM 5.2 and later requires HHVM 3.5.\n\nFluentDOM 4.0 to 5.1 work with HHVM 3.3 but it was limited. If you like to use\nHHVM it is strongly suggest to use newer releases.\n\nFluentDOM 7.0 and later has not support for HHVM any more.\n\n## Packagist\n\nFluentDOM is available on [Packagist.org](https://packagist.org/packages/fluentdom/fluentdom), \njust add the dependency to your composer.json.\n\n```javascript\n{\n  \"require\": {\n    \"fluentdom/fluentdom\": \"^7.0\"\n  }\n}\n```\n\n## Usage\n\nThe following examples load the sample.xml file,\nlook for tags \u0026lt;h1\u003e with the attribute \"id\" that has the value \"title\",\nset the content of these tags to \"Hello World\" and output the manipulated\ndocument.\n\n### Extended DOM (FluentDOM \u003e= 5.2)\n\nUsing the `FluentDOM\\Document` class:\n\n```php\n$fd = FluentDOM::load('sample.xml');\nforeach ($fd('//h1[@id = \"title\"]') as $node) {\n  $node-\u003enodeValue = 'Hello World!';\n}\n\necho $fd-\u003esaveXml();\n```\n\n### jQuery Style API\n\nUsing the `FluentDOM\\Query` class:\n\n```php\necho FluentDOM('sample.xml')\n  -\u003efind('//h1[@id = \"title\"]')\n  -\u003etext('Hello World!');\n```\n\n#### CSS Selectors\n\nIf you install a CSS selector to Xpath translation library into a project,\nyou can use the `FluentDOM::QueryCss()` function. It returns a `FluentDOM\\Query` instance\nsupporting CSS 3 selectors.\n\n```php\n$fd = FluentDOM::QueryCss('sample.xml')\n  -\u003efind('h1#title')\n  -\u003etext('Hello World!');\n```\n\nRead more about it in the [Wiki](https://github.com/ThomasWeinert/FluentDOM/wiki/CSS-Selectors)\n\n### Creating XML\n\nNew features in FluentDOM make it easy to create XML, even XML with namespaces. Basically\nyou can register XML namespaces on the document and methods without direct namespace support \n(like `createElement()`) will resolve the namespace and call the namespace aware variant \n(like `createElementNS()`).\n\nCheck the Wiki for an [example](https://github.com/ThomasWeinert/FluentDOM/wiki/Creating-XML-with-Namespaces-%28Atom%29).\n\n## Backwards Compatibility Breaks\n\n### From 6.2 to 7.0\n\nThe minimum required PHP version now is 7.0. HHVM is not supported any more.\nScalar type hints and return types were added.\n\nMoved the extended DOM classes into the `FluentDOM\\DOM` namespace. \n(`FluentDOM\\Document` -\u003e `FluentDOM\\DOM\\Document`). `FluentDOM\\Nodes\\Creator` was moved\nto `FluentDOM\\Creator`. Several internal classes were moved into a `FluentDOM\\Utiltity`\nnamespace.\n\n`FluentDOM\\Query::get()` now return a `DOMNode`is the position was provided, not an array\nany more.\n\n`FluentDOM\\DOM\\Element::find()` was removed, use `FluentDOM($element)-\u003efind()`.\n\n[Previous BC breaks](https://github.com/ThomasWeinert/FluentDOM/wiki/Backwards-Compatibility) are documented in the Wiki.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThomasWeinert%2FFluentDOM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThomasWeinert%2FFluentDOM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThomasWeinert%2FFluentDOM/lists"}