{"id":19506320,"url":"https://github.com/thenorthmemory/xml","last_synced_at":"2025-07-11T10:34:33.338Z","repository":{"id":60118206,"uuid":"541098950","full_name":"TheNorthMemory/xml","owner":"TheNorthMemory","description":"A wrapper of the XML parser and builder","archived":false,"fork":false,"pushed_at":"2024-09-08T09:50:50.000Z","size":53,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-08T20:54:32.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheNorthMemory.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":"2022-09-25T08:06:55.000Z","updated_at":"2024-09-08T09:50:54.000Z","dependencies_parsed_at":"2023-02-10T12:30:38.310Z","dependency_job_id":null,"html_url":"https://github.com/TheNorthMemory/xml","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNorthMemory%2Fxml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNorthMemory%2Fxml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNorthMemory%2Fxml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNorthMemory%2Fxml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheNorthMemory","download_url":"https://codeload.github.com/TheNorthMemory/xml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224023531,"owners_count":17242989,"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":[],"created_at":"2024-11-10T22:36:39.912Z","updated_at":"2024-11-10T22:36:41.016Z","avatar_url":"https://github.com/TheNorthMemory.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A wrapper of the XML parser and builder\n\nSplit from the wechatpay-php project for general usages.\n\n[![GitHub actions](https://github.com/TheNorthMemory/xml/workflows/CI/badge.svg)](https://github.com/TheNorthMemory/xml/actions)\n[![Packagist Stars](https://img.shields.io/packagist/stars/thenorthmemory/xml)](https://packagist.org/packages/thenorthmemory/xml)\n[![Packagist Downloads](https://img.shields.io/packagist/dm/thenorthmemory/xml)](https://packagist.org/packages/thenorthmemory/xml)\n[![Packagist Version](https://img.shields.io/packagist/v/thenorthmemory/xml)](https://packagist.org/packages/thenorthmemory/xml)\n[![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/thenorthmemory/xml)](https://packagist.org/packages/thenorthmemory/xml)\n[![Packagist License](https://img.shields.io/packagist/l/thenorthmemory/xml)](https://packagist.org/packages/thenorthmemory/xml)\n\n## Install\n\n```shell\ncomposer require thenorthmemory/xml\n```\n\n## Usage\n\n```php\nuse TheNorthMemory\\Xml\\Transformer;\n$array = Transformer::toArray('\u003cxml\u003e\u003chello\u003eworld\u003c/hello\u003e\u003c/xml\u003e');\n// print_r($array);\n// Array\n// (\n//     [hello] =\u003e world\n// )\n$xml = Transformer::toXml($array);\n// print_r($xml);\n// \u003cxml\u003e\u003chello\u003eworld\u003c/hello\u003e\u003c/xml\u003e\n$xml = \u003c\u003c\u003cTencentCOSRequest\n\u003cRequest\u003e\n\u003cOperation\u003e\n \u003cWatermarkTemplateId\u003et146d70eb241c44c63b6efc1cc93ccfc5d\u003c/WatermarkTemplateId\u003e\n \u003cWatermarkTemplateId\u003et12a74d11687d444deba8a6cc52051ac27\u003c/WatermarkTemplateId\u003e\n\u003c/Operation\u003e\n\u003c/Request\u003e\nTencentCOSRequest;\n$array = Transformer::toArray($xml);\n// Array\n// (\n//     [Operation] =\u003e Array\n//         (\n//             [WatermarkTemplateId] =\u003e Array\n//                 (\n//                     [0] =\u003e t146d70eb241c44c63b6efc1cc93ccfc5d\n//                     [1] =\u003e t12a74d11687d444deba8a6cc52051ac27\n//                 )\n\n//         )\n\n// )\n$xml1 = Transformer::toXml($array, true, true, 'Request');\n// print_r($xml1);\n// \u003cRequest\u003e\n//  \u003cOperation\u003e\n//   \u003cWatermarkTemplateId\u003e\n//    \u003citem\u003et146d70eb241c44c63b6efc1cc93ccfc5d\u003c/item\u003e\n//    \u003citem\u003et12a74d11687d444deba8a6cc52051ac27\u003c/item\u003e\n//   \u003c/WatermarkTemplateId\u003e\n//  \u003c/Operation\u003e\n// \u003c/Request\u003e\n$array['Operation']['WatermarkTemplateId'] = Transformer::wrap($array['Operation']['WatermarkTemplateId'], true, 'WatermarkTemplateId');\n$xml2 = Transformer::toXml($array, true, true, 'Request');\n// print_r($xml2);\n// \u003cRequest\u003e\n// \u003cOperation\u003e\n//  \u003cWatermarkTemplateId\u003et146d70eb241c44c63b6efc1cc93ccfc5d\u003c/WatermarkTemplateId\u003e\n//  \u003cWatermarkTemplateId\u003et12a74d11687d444deba8a6cc52051ac27\u003c/WatermarkTemplateId\u003e\n// \u003c/Operation\u003e\n// \u003c/Request\u003e\n```\n\n## API\n\n**`Transformer::toArray(string $xml = '\u003cxml/\u003e')`**\n\nParse the XML `string` to `array`.\n\n**`Transformer::sanitize(string $xml = '\u003cxml/\u003e')`**\n\nSanitize the XML `string` in the [XML1.0 20081126 Character Range](https://www.w3.org/TR/2008/REC-xml-20081126/#charsets).\n\n**`Transformer::toXml(array $data, bool $headless = true, bool $indent = false, string $root = 'xml', string $item = 'item'): string`**\n\nBuild the data `array` to XML `string`.\n\n**`Transformer::wrap(array $data, bool $wrapped = false, string $label = 'item'): LabeledArrayIterator`**\n\nWrap the `array` data with a `label` and `wrapped` flag.\n\n## License\n\n[Apache-2.0 License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenorthmemory%2Fxml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthenorthmemory%2Fxml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenorthmemory%2Fxml/lists"}