{"id":25806000,"url":"https://github.com/alipsa/xmlr","last_synced_at":"2025-02-27T19:52:35.668Z","repository":{"id":56936340,"uuid":"252530646","full_name":"Alipsa/xmlr","owner":"Alipsa","description":"XML dom package for R similar to jdom implemented using Reference Classes","archived":false,"fork":false,"pushed_at":"2022-03-06T16:58:58.000Z","size":175,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T23:16:33.583Z","etag":null,"topics":["r-package","renjin"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alipsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["Alipsa"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-04-02T18:07:12.000Z","updated_at":"2023-02-25T17:10:56.000Z","dependencies_parsed_at":"2022-08-21T06:20:38.128Z","dependency_job_id":null,"html_url":"https://github.com/Alipsa/xmlr","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/Alipsa%2Fxmlr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Fxmlr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Fxmlr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Fxmlr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alipsa","download_url":"https://codeload.github.com/Alipsa/xmlr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241052529,"owners_count":19901043,"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":["r-package","renjin"],"created_at":"2025-02-27T19:52:34.624Z","updated_at":"2025-02-27T19:52:35.660Z","avatar_url":"https://github.com/Alipsa.png","language":"R","funding_links":["https://github.com/sponsors/Alipsa"],"categories":[],"sub_categories":[],"readme":"# xmlr\nXML dom package for R implemented using Reference Classes\n\nThe jdom project (www.jdom.org) provided a lot of initial inspiration for the api but there are several differences, mainly \n- Attributes: Attribute is not a specific class but just a name value element of the named list property of an Element\n- Namespaces:\n    Whereas in jdom namespaces is a special class that exists as a specific object attribute, xmlr takes a \"simpler\"\n    approach in the sense that namespace declarations are just another element attribute and name space prefixes are part of the \n    element name. This might change in the future but for now this is how it is done.\n\nYou can create and xmlr Document programmatically or by parsing text or a file. \n\n# Creating the DOM programmatically\nTo create the following xml\n```xml\n\u003ctable xmlns='http://www.w3.org/TR/html4/'\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eApples\u003c/td\u003e\n        \u003ctd\u003eBananas\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n```\nYou could do something like this:\n```r\n doc \u003c- Document$new()\n  root \u003c- Element$new(\"table\")\n  root$setAttribute(\"xmlns\", \"http://www.w3.org/TR/html4/\")\n\n  root$addContent(\n    Element$new(\"tr\")\n      $addContent(Element$new(\"td\")$setText(\"Apples\"))\n      $addContent(Element$new(\"td\")$setText(\"Bananas\"))\n  )\n  doc$setRootElement(root)\n```\nOr you could do like this:\n```r\ndoc2 \u003c- parse.xmlstring(\"\n\u003ctable xmlns='http://www.w3.org/TR/html4/'\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eApples\u003c/td\u003e\n        \u003ctd\u003eBananas\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\")\n```\nNote that there is no pretty print available (yet) so if you print it `print(doc2)`\nit will look like this:\n```\n\u003e print(doc2)\n\u003ctable xmlns='http://www.w3.org/TR/html4/'\u003e\u003ctr\u003e\u003ctd\u003eApples\u003c/td\u003e\u003ctd\u003eBananas\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\u003e \n```\n\n# using xmlr\nxmlr is published both to CRAN for use in GNU R and to Maven Central for use in Renjin.\nFor cran it is as simple as `install.packages('xmlr')` followed by `library('xmlr')`.\nFor renjin add the following to your pom.xml:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ese.alipsa\u003c/groupId\u003e\n  \u003cartifactId\u003exmlr\u003c/artifactId\u003e\n  \u003cversion\u003e0.2.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n...and then `library('se.alipsa:xmlr')`\n\n# Limitations\nProcessing instructions, custom entity references, and comments are not yet supported.\n\nAny proper xml including CDATA, comments, processing instructions etc. can be parsed though, it is just that\nonly elements, attributes and text will be retained.\n\nCDATA can be read from string or file but handled as ordinary text after that. I.e. the output might not be valid XML.\n\nThere are probably issues (memory, performance) with very large XML trees.\n\n# Why xmlr?\nI had problems on one of my machines to install the XML package (some gcc issue) so needed an alternative.\nAs I have been thinking about doing something more comprehensive with Reference Classes I decided to create\na pure base-R DOM model with some simple ways to do input and output to strings and files. As it turned out to\nbe useful to me, I thought it might be for others as well, so I decided to open source and publish it.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falipsa%2Fxmlr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falipsa%2Fxmlr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falipsa%2Fxmlr/lists"}