{"id":23505090,"url":"https://github.com/krosscode/xml-to-object","last_synced_at":"2025-05-07T05:31:10.326Z","repository":{"id":57009372,"uuid":"221893994","full_name":"krosscode/xml-to-object","owner":"krosscode","description":"PHP library for converting XML contents to objects","archived":false,"fork":false,"pushed_at":"2019-11-15T11:48:23.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-16T18:25:09.873Z","etag":null,"topics":["composer-package","converter","object","php","php-library","php7","xml"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krosscode.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}},"created_at":"2019-11-15T09:49:34.000Z","updated_at":"2020-02-07T12:22:46.000Z","dependencies_parsed_at":"2022-08-21T14:50:52.856Z","dependency_job_id":null,"html_url":"https://github.com/krosscode/xml-to-object","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krosscode%2Fxml-to-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krosscode%2Fxml-to-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krosscode%2Fxml-to-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krosscode%2Fxml-to-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krosscode","download_url":"https://codeload.github.com/krosscode/xml-to-object/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252822969,"owners_count":21809700,"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":["composer-package","converter","object","php","php-library","php7","xml"],"created_at":"2024-12-25T09:18:35.891Z","updated_at":"2025-05-07T05:31:10.294Z","avatar_url":"https://github.com/krosscode.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XML to object\n\nThis library simply converts XML into an object.\n\n## Getting started\n\nXML to object is very easy to use. **Example:**\n\n```php\n// Using composer here, but you can also directly include XmlToObject.php\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n// Import the function\nuse function KrossCode\\XmlToObject\\xmlToObject;\n\n// First we need to get the contents of our XML file\n$xmlContents = file_get_contents('path/to/xml/file.xml');\nif (!$xmlContents) return false; // File couldn't be read\n\n// Now we try to convert the XML to an object\n$xmlObject = xmlToObject($xmlContents);\nif (!$xmlObject) return false; // XML couldn't be converted to an object\n\nprint_r($xmlObject); // Success!\n```\n\n## Example\n\nWhat does the object look like, compared to the XML?\n\n### XML\n\n```xml\n\u003cGroceryStore xmlns=\"https://example.com/schema/base\" xmlns:ns3=\"https://example.com/schema/ns3\"\u003e\n\t\u003cName\u003eJohnny's Green Goods\u003c/Name\u003e\n\t\u003cGroceryCollection\u003e\n\t\t\u003cns3:Grocery id=\"13\"\u003e\n\t\t\t\u003cName\u003eCucumber\u003c/Name\u003e\n\t\t\t\u003cAmount\u003e63\u003c/Amount\u003e\n\t\t\t\u003cPrice\u003e1.99\u003c/Price\u003e\n\t\t\u003c/ns3:Grocery\u003e\n\t\t\u003cns3:Grocery id=\"17\"\u003e\n\t\t\t\u003cName\u003eCarrot\u003c/Name\u003e\n\t\t\t\u003cAmount\u003e24\u003c/Amount\u003e\n\t\t\t\u003cPrice\u003e1.79\u003c/Price\u003e\n\t\t\u003c/ns3:Grocery\u003e\n\t\u003c/GroceryCollection\u003e\n\u003c/GroceryStore\u003e\n```\n\n### Object (represented in JSON)\n\n```json\n{\n    \"Name\": \"Johnny's Green Goods\",\n    \"GroceryCollection\": {\n        \"Grocery\": [\n            {\n                \"@attributes\": {\n                    \"id\": \"13\"\n                },\n                \"Name\": \"Cucumber\",\n                \"Amount\": \"63\",\n                \"Price\": \"1.99\"\n            },\n            {\n                \"@attributes\": {\n                    \"id\": \"17\"\n                },\n                \"Name\": \"Carrot\",\n                \"Amount\": \"24\",\n                \"Price\": \"1.79\"\n            }\n        ]\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrosscode%2Fxml-to-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrosscode%2Fxml-to-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrosscode%2Fxml-to-object/lists"}