{"id":27118627,"url":"https://github.com/doga/xml","last_synced_at":"2025-04-07T07:59:11.359Z","repository":{"id":233964837,"uuid":"788100052","full_name":"doga/xml","owner":"doga","description":"An XML parser and writer with namespace support. Packaged as a JavaScript ES6 module.","archived":false,"fork":false,"pushed_at":"2024-04-17T20:39:35.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-18T20:39:12.678Z","etag":null,"topics":["runnable-readme","xml","xml-parser","xml-serializer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/doga.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}},"created_at":"2024-04-17T19:19:36.000Z","updated_at":"2024-04-17T20:41:06.000Z","dependencies_parsed_at":"2024-04-17T20:49:53.180Z","dependency_job_id":null,"html_url":"https://github.com/doga/xml","commit_stats":null,"previous_names":["doga/xml"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2Fxml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2Fxml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2Fxml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2Fxml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doga","download_url":"https://codeload.github.com/doga/xml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615456,"owners_count":20967183,"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":["runnable-readme","xml","xml-parser","xml-serializer"],"created_at":"2025-04-07T07:59:10.700Z","updated_at":"2025-04-07T07:59:11.350Z","avatar_url":"https://github.com/doga.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XML parser and writer\n\nAn XML parser and writer with namespace support. Packaged as a JavaScript ES6 module.\n\n## Usage examples\n\n_Tip: Run the examples below by typing this in your terminal (requires Deno):_\n\n```shell\ndeno run \\\n  --allow-net --allow-run --allow-env --allow-read \\\n  https://deno.land/x/mdrb@2.0.0/mod.ts \\\n  --dax=false --mode=isolated \\\n  https://raw.githubusercontent.com/doga/xml/master/README.md\n```\n\n\u003cdetails data-mdrb\u003e\n\u003csummary\u003eExample: Parse and re-generate an XML string.\u003c/summary\u003e\n\n\u003cpre\u003e\ndescription = '''\nRunning this example is safe, it will not read or write anything to your filesystem.\n'''\n\u003c/pre\u003e\n\u003c/details\u003e\n\n```javascript\nimport { Parser, Writer } from 'https://esm.sh/gh/doga/xml@1.0.0/mod.mjs';\n\nconst \nxml = \n`\u003c!-- \n  A Qworum script that calls a login endpoint.\n  The Web application uses the Qworum browser extension\n  to run the script.\n--\u003e\n\u003csequence xmlns='https://qworum.net/ns/v1/instruction/'\u003e\n  \u003ctry\u003e\n    \u003ccall href='/login' /\u003e\n    \u003ccatch faults='[\"* cancelled\"]'\u003e\n      \u003cgoto href='/loginCancelled' /\u003e\n    \u003c/catch\u003e\n    \u003ccatch faults='[\"* failed\"]'\u003e\n      \u003cgoto href='/loginFailed' /\u003e\n    \u003c/catch\u003e\n  \u003c/try\u003e\n  \u003cgoto href='/account' /\u003e\n\u003c/sequence\u003e`,\n\ndoc = new Parser(xml).document, // XmlDocument\n\n// serialise the root element\nxml2 = Writer.elementToString(doc.root);\n\nconsole.info(xml2);\n```\n\nSample output for the code above:\n\n```text\n\u003csequence xmlns=\"https://qworum.net/ns/v1/instruction/\"\u003e\n  \u003ctry\u003e\n    \u003ccall href=\"/login\"\u003e\u003c/call\u003e\n    \u003ccatch faults=\"[\u0026quot;* cancelled\u0026quot;]\"\u003e\n      \u003cgoto href=\"/loginCancelled\"\u003e\u003c/goto\u003e\n    \u003c/catch\u003e\n    \u003ccatch faults=\"[\u0026quot;* failed\u0026quot;]\"\u003e\n      \u003cgoto href=\"/loginFailed\"\u003e\u003c/goto\u003e\n    \u003c/catch\u003e\n  \u003c/try\u003e\n  \u003cgoto href=\"/account\"\u003e\u003c/goto\u003e\n\u003c/sequence\u003e\n```\n\n\u003cdetails data-mdrb\u003e\n\u003csummary\u003eExample: Build an XML document programmatically.\u003c/summary\u003e\n\n\u003cpre\u003e\ndescription = '''\nRunning this example is safe, it will not read or write anything to your filesystem.\n'''\n\u003c/pre\u003e\n\u003c/details\u003e\n\n```javascript\nimport { Parser, Writer, XmlDocument, XmlElement, XmlComment } from 'https://esm.sh/gh/doga/xml@1.0.0/mod.mjs';\n\nconst \ndoc = new XmlDocument([\n  new XmlComment(\n    `A Qworum script that calls a login endpoint.\n    The Web application uses the Qworum browser extension\n    to run the script.`\n  ),\n  new XmlElement(\n    'sequence', {xmlns: 'https://qworum.net/ns/v1/instruction/'},\n    [\n      new XmlElement(\n        'try', {},\n        [\n          new XmlElement('call', {href: '/login'}),\n          new XmlElement(\n            'catch', {faults: '[\"* cancelled\"]'},\n            [new XmlElement('goto', {href: '/loginCancelled'})]\n          ),\n          new XmlElement(\n            'catch', {faults: '[\"* failed\"]'},\n            [new XmlElement('goto', {href: '/loginFailed'})]\n          ),\n        ]\n      ),\n      new XmlElement('goto', {href: '/account'}),\n    ]\n  )\n]),\n\n// serialise the root element\nxml = Writer.elementToString(doc.root);\n\nconsole.info(xml);\n```\n\nSample output for the code above:\n\n```text\n\u003csequence xmlns=\"https://qworum.net/ns/v1/instruction/\"\u003e\u003ctry\u003e\u003ccall href=\"/login\"\u003e\u003c/call\u003e\u003ccatch faults=\"[\u0026quot;* cancelled\u0026quot;]\"\u003e\u003cgoto href=\"/loginCancelled\"\u003e\u003c/goto\u003e\u003c/catch\u003e\u003ccatch faults=\"[\u0026quot;* failed\u0026quot;]\"\u003e\u003cgoto href=\"/loginFailed\"\u003e\u003c/goto\u003e\u003c/catch\u003e\u003c/try\u003e\u003cgoto href=\"/account\"\u003e\u003c/goto\u003e\u003c/sequence\u003e\n```\n\n∎\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoga%2Fxml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoga%2Fxml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoga%2Fxml/lists"}