{"id":18637519,"url":"https://github.com/dutchcoders/xmlgen","last_synced_at":"2025-10-16T07:08:00.304Z","repository":{"id":29875767,"uuid":"33421034","full_name":"dutchcoders/XMLGen","owner":"dutchcoders","description":"XMLGen is a tool for generating native Golang types from XML.","archived":false,"fork":false,"pushed_at":"2016-01-29T08:41:04.000Z","size":78,"stargazers_count":76,"open_issues_count":0,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-11T16:14:54.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/dutchcoders.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":"2015-04-04T21:30:00.000Z","updated_at":"2025-02-19T17:36:03.000Z","dependencies_parsed_at":"2022-09-06T11:33:52.506Z","dependency_job_id":null,"html_url":"https://github.com/dutchcoders/XMLGen","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/dutchcoders/XMLGen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchcoders%2FXMLGen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchcoders%2FXMLGen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchcoders%2FXMLGen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchcoders%2FXMLGen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dutchcoders","download_url":"https://codeload.github.com/dutchcoders/XMLGen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchcoders%2FXMLGen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279164423,"owners_count":26117697,"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","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-07T05:36:34.541Z","updated_at":"2025-10-16T07:08:00.274Z","avatar_url":"https://github.com/dutchcoders.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Purpose\nXMLGen is a tool for generating native Golang types from XML. This automates what is otherwise a very tedious and error prone task when working with XML.\n\n[![Build Status](http://img.shields.io/travis/dutchcoders/XMLGen.svg?style=flat)](https://travis-ci.org/dutchcoders/XMLGen)\n[![GPLv3 License](http://img.shields.io/badge/license-GPLv3-blue.svg?style=flat)](http://choosealicense.com/licenses/gpl-3.0/)\n\nXMLGen is based on and using code from [JSONGen](https://github.com/bemasher/JSONGen).\n\n## Install (using brew)\n\n```\nbrew tap dutchcoders/homebrew-xmlgen\nbrew install xmlgen\n```\n\n## Usage\n\n```\n$ xmlgen -h\nUsage of xmlgen:\n  -dump=\"NUL\": Dump tree structure to file.\n  -normalize=true: Squash arrays of struct and determine primitive array type.\n  -title=true: Convert identifiers to title case, treating '_' and '-' as word boundaries.\n```\n\nReading from stdin can be done as follows:\n```\n$ cat test.xml | xmlgen\n```\n\nOr a filename can be passed:\n```\n$ xmlgen test.xml\n```\n\nUsing [test.xml](test.xml) as input the example will produce:\n```go\n➜ xmlgen git:(master) ✗ curl http://www.ibiblio.org/xml/examples/shakespeare/all_well.xml | xmlgen\ntype _ struct {\n        PLAY struct {\n                TITLE string `xml:\"TITLE\"`\n                FM    struct {\n                        P []string `xml:\"P\"`\n                } `xml:\"FM\"`\n                PERSONAE struct {\n                        TITLE   string   `xml:\"TITLE\"`\n                        PERSONA []string `xml:\"PERSONA\"`\n                        PGROUP  struct {\n                                PERSONA  []string `xml:\"PERSONA\"`\n                                GRPDESCR string   `xml:\"GRPDESCR\"`\n                        } `xml:\"PGROUP\"`\n                        PERSONA []string `xml:\"PERSONA\"`\n                        PGROUP  struct {\n                                PERSONA  []string `xml:\"PERSONA\"`\n                                GRPDESCR string   `xml:\"GRPDESCR\"`\n                        } `xml:\"PGROUP\"`\n                        PERSONA string `xml:\"PERSONA\"`\n                } `xml:\"PERSONAE\"`\n                SCNDESCR string `xml:\"SCNDESCR\"`\n                PLAYSUBT string `xml:\"PLAYSUBT\"`\n                ACT      []struct {\n                        TITLE string `xml:\"TITLE\"`\n                        SCENE []struct {\n                                TITLE    string `xml:\"TITLE\"`\n                                STAGEDIR string `xml:\"STAGEDIR\"`\n                                SPEECH   []struct {\n                                        SPEAKER  string `xml:\"SPEAKER\"`\n                                        LINE     string `xml:\"LINE\"`\n                                        STAGEDIR string `xml:\"STAGEDIR\"`\n                                } `xml:\"SPEECH\"`\n                                STAGEDIR string `xml:\"STAGEDIR\"`\n                                SPEECH   []struct {\n                                        SPEAKER  string   `xml:\"SPEAKER\"`\n                                        LINE     []string `xml:\"LINE\"`\n                                        STAGEDIR string   `xml:\"STAGEDIR\"`\n                                } `xml:\"SPEECH\"`\n                                STAGEDIR string `xml:\"STAGEDIR\"`\n                                SPEECH   []struct {\n                                        SPEAKER  string   `xml:\"SPEAKER\"`\n                                        LINE     []string `xml:\"LINE\"`\n                                        STAGEDIR []string `xml:\"STAGEDIR\"`\n                                        LINE     []string `xml:\"LINE\"`\n                                } `xml:\"SPEECH\"`\n                                STAGEDIR string `xml:\"STAGEDIR\"`\n                                SPEECH   struct {\n                                        SPEAKER  string `xml:\"SPEAKER\"`\n                                        LINE     string `xml:\"LINE\"`\n                                        STAGEDIR string `xml:\"STAGEDIR\"`\n                                } `xml:\"SPEECH\"`\n                                STAGEDIR string `xml:\"STAGEDIR\"`\n                                SPEECH   []struct {\n                                        SPEAKER  string   `xml:\"SPEAKER\"`\n                                        LINE     []string `xml:\"LINE\"`\n                                        STAGEDIR string   `xml:\"STAGEDIR\"`\n                                } `xml:\"SPEECH\"`\n                                STAGEDIR string `xml:\"STAGEDIR\"`\n                                SPEECH   struct {\n                                        SPEAKER  string   `xml:\"SPEAKER\"`\n                                        LINE     []string `xml:\"LINE\"`\n                                        STAGEDIR string   `xml:\"STAGEDIR\"`\n                                } `xml:\"SPEECH\"`\n                                STAGEDIR string `xml:\"STAGEDIR\"`\n                        } `xml:\"SCENE\"`\n                        EPILOGUE struct {\n                                TITLE  string `xml:\"TITLE\"`\n                                SPEECH struct {\n                                        SPEAKER string   `xml:\"SPEAKER\"`\n                                        LINE    []string `xml:\"LINE\"`\n                                } `xml:\"SPEECH\"`\n                                STAGEDIR string `xml:\"STAGEDIR\"`\n                        } `xml:\"EPILOGUE\"`\n                } `xml:\"ACT\"`\n        } `xml:\"PLAY\"`\n}\n```\n\n## Parsing\n### Field Names\n  * Field names are sanitized and written as exported fields of the generated type.\n  * If sanitizing produces an empty string the identifier is changed to `_`, this will need to be set by hand in order to properly decode the type.\n  * Spaces and `-` are converted to `_`.\n  * Field names are converted to title case treating `_` and `-` as word boundaries along with spaces. This can be disabled using `-title=false`.\n\n## Types\n### Primitive\n  * Primitive types are parsed and stored as-is.\n  * Valid types are currently only strings\n\n### Object\n  * Object types are treated as structs.\n  * Fields of structures are sorted lexicographically by sanitized field name.\n\n### Lists\n  * A homogeneous list of recurring elements with the same name the primitive type e.g.: `[]string`\n  * Lists with object elements are treated as a list of structs.\n    * Fields of each element are \"squashed\" into a single struct. The result is an array of a struct containing all encountered fields.   \n\nExamples of all of the above can be found in [test.xml](test.xml).\n\n## Caveats\n  * Currently sibling field names are not guaranteed to be unique.\n\n## License\nThe source of this project is licensed under GNU GPL v3.0, according to [http://choosealicense.com/licenses/gpl-3.0/](http://choosealicense.com/licenses/gpl-3.0/):\n\n#### Required:\n\n * **Disclose Source:** Source code must be made available when distributing the software. In the case of LGPL, the source for the library (and not the entire program) must be made available.\n * **License and copyright notice:** Include a copy of the license and copyright notice with the code.\n * **State Changes:** Indicate significant changes made to the code.\n\n#### Permitted:\n\n * **Commercial Use:** This software and derivatives may be used for commercial purposes.\n * **Distribution:** You may distribute this software.\n * **Modification:** This software may be modified.\n * **Patent Grant:** This license provides an express grant of patent rights from the contributor to the recipient.\n * **Private Use:** You may use and modify the software without distributing it.\n\n#### Forbidden:\n\n * **Hold Liable:** Software is provided without warranty and the software author/license owner cannot be held liable for damages.\n * **Sublicensing:** You may not grant a sublicense to modify and distribute this software to third parties not included in the license.\n\n## Feedback\nIf you find a case that produces incorrect results or you have a feature suggestion, let me know: submit an issue.\n\n## Creators\n\n**Remco Verhoef**\n- \u003chttps://twitter.com/remco_verhoef\u003e\n- \u003chttps://twitter.com/dutchcoders\u003e\n\nDouglas Hall is the creator of JSONGen. XMLGen is based and using code from [JSONGen](https://github.com/bemasher/JSONGen).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutchcoders%2Fxmlgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdutchcoders%2Fxmlgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutchcoders%2Fxmlgen/lists"}