{"id":15477936,"url":"https://github.com/byjg/php-anydataset-xml","last_synced_at":"2025-08-01T12:10:37.850Z","repository":{"id":62498591,"uuid":"158025803","full_name":"byjg/php-anydataset-xml","owner":"byjg","description":"Anydataset Xml abstraction. Anydataset is an agnostic data source abstraction layer in PHP","archived":false,"fork":false,"pushed_at":"2024-09-11T23:23:37.000Z","size":28,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T03:05:03.485Z","etag":null,"topics":["anydataset","php","xml","xml-anydataset","xml-parsing"],"latest_commit_sha":null,"homepage":null,"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/byjg.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-11-17T21:18:48.000Z","updated_at":"2024-06-11T01:46:04.000Z","dependencies_parsed_at":"2024-06-10T03:26:35.492Z","dependency_job_id":"4ffa6c05-3251-4535-9bc2-8d9691e21f93","html_url":"https://github.com/byjg/php-anydataset-xml","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"c04a6366e39b0c9497ffca1cc4e471acc2667c82"},"previous_names":["byjg/php-anydataset-xml"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byjg%2Fphp-anydataset-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byjg%2Fphp-anydataset-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byjg%2Fphp-anydataset-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byjg%2Fphp-anydataset-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byjg","download_url":"https://codeload.github.com/byjg/php-anydataset-xml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250256884,"owners_count":21400608,"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":["anydataset","php","xml","xml-anydataset","xml-parsing"],"created_at":"2024-10-02T04:01:36.871Z","updated_at":"2025-04-22T14:24:38.202Z","avatar_url":"https://github.com/byjg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AnyDataset-Xml\n\n[![Build Status](https://github.com/byjg/php-anydataset-xml/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-anydataset-xml/actions/workflows/phpunit.yml) \n[![Opensource ByJG](https://img.shields.io/badge/opensource-byjg-success.svg)](http://opensource.byjg.com) \n[![GitHub source](https://img.shields.io/badge/Github-source-informational?logo=github)](https://github.com/byjg/php-anydataset-xml/) \n[![GitHub license](https://img.shields.io/github/license/byjg/php-anydataset-xml.svg)](https://opensource.byjg.com/opensource/licensing.html) \n[![GitHub release](https://img.shields.io/github/release/byjg/php-anydataset-xml.svg)](https://github.com/byjg/php-anydataset-xml/releases/)\n\nXML abstraction dataset. Anydataset is an agnostic data source abstraction layer in PHP. \n\nSee more about Anydataset [here](https://opensource.byjg.com/php/anydataset).\n\n## Examples\n\n### Simple Manipulation\n\nexample1.xml\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cbookstore\u003e\n    \u003cbook category=\"COOKING\"\u003e\n        \u003ctitle lang=\"en-US\"\u003eEveryday Italian\u003c/title\u003e\n        \u003cauthor\u003eGiada De Laurentiis\u003c/author\u003e\n        \u003cyear\u003e2005\u003c/year\u003e\n        \u003cprice\u003e30.00\u003c/price\u003e\n    \u003c/book\u003e\n    \u003cbook category=\"CHILDREN\"\u003e\n        \u003ctitle lang=\"de-DE\"\u003eHarry Potter\u003c/title\u003e\n        \u003cauthor\u003eJ K. Rowling\u003c/author\u003e\n        \u003cyear\u003e2005\u003c/year\u003e\n        \u003cprice\u003e29.99\u003c/price\u003e\n    \u003c/book\u003e\n    \u003cbook category=\"WEB\"\u003e\n        \u003ctitle lang=\"pt-BR\"\u003eLearning XML\u003c/title\u003e\n        \u003cauthor\u003eErik T. Ray\u003c/author\u003e\n        \u003cyear\u003e2003\u003c/year\u003e\n        \u003cprice\u003e39.95\u003c/price\u003e\n    \u003c/book\u003e\n\u003c/bookstore\u003e\n```\n\nexample1.php\n```php\n\u003c?php\n$xml = file_get_contents('example1.xml');\n\n$dataset = new \\ByJG\\AnyDataset\\Xml\\XmlDataset(\n    $xml,        // The Xml\n    \"book\",       // The node that represents a row\n    [\n        \"category\" =\u003e \"@category\",\n        \"title\" =\u003e \"title\",\n        \"lang\" =\u003e \"title/@lang\",\n        \"lang2\" =\u003e function ($row) {\n            return substr($row-\u003eget('lang'), 0, 2);\n        }\n    ] // Mapping columns\n);\n\n$iterator = $dataset-\u003egetIterator();\nforeach ($iterator as $row) {\n    echo $row-\u003eget('category'); // Print COOKING, CHILDREN, WEB\n    echo $row-\u003eget('title');    // Print Everyday Italian, Harry Potter, Learning Xml\n    echo $row-\u003eget('lang');     // Print en-US, de-DE, pt-BR\n    echo $row-\u003eget('lang2');    // Print en, de, pt\n}\n```\n\n### Xml with namespaces\n\nexample2.xml\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cfeed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:batch=\"http://schemas.google.com/gdata/batch\" xmlns:gContact=\"http://schemas.google.com/contact/2008\" xmlns:gd=\"http://schemas.google.com/g/2005\" xmlns:openSearch=\"http://a9.com/-/spec/opensearchrss/1.0/\"\u003e\n    \u003cid\u003emyId\u003c/id\u003e\n    \u003cupdated\u003e2014-09-15T19:35:55.795Z\u003c/updated\u003e\n    \u003ccategory scheme=\"http://schemas.google.com/g/2005#kind\" term=\"gContact#contact\"/\u003e\n    \u003ctitle type=\"text\"\u003eTitle\u003c/title\u003e\n    \u003clink rel=\"alternate\" type=\"text/html\" href=\"https://www.google.com/\"/\u003e\n    \u003clink rel=\"http://schemas.google.com/g/2005#feed\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full\"/\u003e\n    \u003clink rel=\"http://schemas.google.com/g/2005#post\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full\"/\u003e\n    \u003clink rel=\"http://schemas.google.com/g/2005#batch\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/batch\"/\u003e\n    \u003clink rel=\"self\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full?max-results=20\"/\u003e\n    \u003clink rel=\"next\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full?max-results=20\u0026amp;start-index=21\"/\u003e\n    \u003cauthor\u003e\n        \u003cname\u003eMy Name\u003c/name\u003e\n        \u003cemail\u003eMy Email\u003c/email\u003e\n    \u003c/author\u003e\n    \u003cgenerator version=\"1.0\" uri=\"http://www.google.com/m8/feeds\"\u003eContacts\u003c/generator\u003e\n    \u003copenSearch:totalResults\u003e2107\u003c/openSearch:totalResults\u003e\n    \u003copenSearch:startIndex\u003e1\u003c/openSearch:startIndex\u003e\n    \u003copenSearch:itemsPerPage\u003e20\u003c/openSearch:itemsPerPage\u003e\n    \u003centry\u003e\n        \u003cid\u003ehttp://www.google.com/m8/feeds/contacts/my%40gmail.com/base/0\u003c/id\u003e\n        \u003cupdated\u003e2013-10-05T22:16:03.564Z\u003c/updated\u003e\n        \u003ccategory scheme=\"http://schemas.google.com/g/2005#kind\" term=\"gContact#contact\"/\u003e\n        \u003ctitle type=\"text\"\u003ePerson 1\u003c/title\u003e\n        \u003clink rel=\"http://schemas.google.com/contacts/2008/rel#edit-photo\" type=\"image/*\" href=\"https://www.google.com/m8/feeds/photos/media/my%40gmail.com/1/ABCDE\"/\u003e\n        \u003clink rel=\"http://schemas.google.com/contacts/2008/rel#photo\" type=\"image/*\" href=\"https://www.google.com/m8/feeds/photos/media/my%40gmail.com/1\"/\u003e\n        \u003clink rel=\"self\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/0\"/\u003e\n        \u003clink rel=\"edit\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/0/1234\"/\u003e\n        \u003cgd:email rel=\"http://schemas.google.com/g/2005#other\" address=\"p1@gmail.com\" primary=\"true\"/\u003e\n    \u003c/entry\u003e\n    \u003centry\u003e\n        \u003cid\u003ehttp://www.google.com/m8/feeds/contacts/my%40gmail.com/base/1\u003c/id\u003e\n        \u003cupdated\u003e2012-07-12T17:19:17.546Z\u003c/updated\u003e\n        \u003ccategory scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/contact/2008#contact\"/\u003e\n        \u003ctitle type=\"text\"\u003ePerson 2\u003c/title\u003e\n        \u003clink rel=\"http://schemas.google.com/contacts/2008/rel#edit-photo\" type=\"image/*\" href=\"https://www.google.com/m8/feeds/photos/media/my%40gmail.com/1/EDFGH\"/\u003e\n        \u003clink rel=\"http://schemas.google.com/contacts/2008/rel#photo\" type=\"image/*\" href=\"https://www.google.com/m8/feeds/photos/media/my%40gmail.com/1\"/\u003e\n        \u003clink rel=\"self\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/1\"/\u003e\n        \u003clink rel=\"edit\" type=\"application/atom+xml\" href=\"https://www.google.com/m8/feeds/contacts/my%40gmail.com/full/1/5678\"/\u003e\n        \u003cgd:email rel=\"http://schemas.google.com/g/2005#other\" address=\"p2@gmail.com\" primary=\"true\"/\u003e\n    \u003c/entry\u003e\u003c/feed\u003e\n```\n\nexample2.php\n```php\n\u003c?php\n$xml = file_get_contents('example2.xml')\n\n$namespace = array(\n    \"fake\" =\u003e \"http://www.w3.org/2005/Atom\",\n    \"gd\" =\u003e \"http://schemas.google.com/g/2005\"\n);\n\n$rootNode = 'fake:entry';\n$colNode = array(\"id\" =\u003e \"fake:id\", \"updated\" =\u003e \"fake:updated\", \"name\" =\u003e \"fake:title\", \"email\" =\u003e \"gd:email/@address\");\n$xmlDataset = new \\ByJG\\AnyDataset\\Xml\\XmlDataset(\n    $xml,\n    $rootNode,\n    $colNode,\n    $namespace\n);\n$xmlIterator = $xmlDataset-\u003egetIterator();\n```\n\n## Install\n\n```\ncomposer require \"byjg/anydataset-xml\"\n```\n\n## Running the Unit tests\n\n```bash\nvendor/bin/phpunit\n```\n\n## Dependencies\n\n```mermaid\nflowchart TD\n    byjg/anydataset-xml --\u003e byjg/anydataset\n    byjg/anydataset-xml --\u003e ext-dom\n```\n----\n[Open source ByJG](http://opensource.byjg.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyjg%2Fphp-anydataset-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyjg%2Fphp-anydataset-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyjg%2Fphp-anydataset-xml/lists"}