{"id":26466726,"url":"https://github.com/js-bits/dom-parser","last_synced_at":"2026-04-10T15:02:54.675Z","repository":{"id":57122328,"uuid":"380634051","full_name":"js-bits/dom-parser","owner":"js-bits","description":"Cross-environment (nodejs/web) DOM parser for XML and HTML","archived":false,"fork":false,"pushed_at":"2023-07-19T03:04:37.000Z","size":614,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-11T09:24:55.043Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/js-bits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-27T02:25:45.000Z","updated_at":"2023-07-03T20:53:17.000Z","dependencies_parsed_at":"2022-08-24T14:59:27.280Z","dependency_job_id":null,"html_url":"https://github.com/js-bits/dom-parser","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bits%2Fdom-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bits%2Fdom-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bits%2Fdom-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bits%2Fdom-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/js-bits","download_url":"https://codeload.github.com/js-bits/dom-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244430055,"owners_count":20451601,"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":"2025-03-19T12:37:24.329Z","updated_at":"2025-12-30T20:59:22.741Z","avatar_url":"https://github.com/js-bits.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cross-environment (nodejs/web) DOM parser for XML and HTML\n\nThis package uses built-in [DOMParser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser) in a browser and [jsdom](https://www.npmjs.com/package/jsdom) module in a Node.js environment and exports `parse` function.\n\n## Installation\n\nInstall with npm:\n\n```\nnpm install @js-bits/dom-parser\n```\n\nInstall with yarn:\n\n```\nyarn add @js-bits/dom-parser\n```\n\nImport where you need it:\n\n```javascript\nimport parse from '@js-bits/dom-parser';\n```\n\nor require for CommonJS:\n\n```javascript\nconst parse = require('@js-bits/dom-parser');\n```\n\n## How to use\n\n```javascript\nconst xml = `\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cnote\u003e\n  \u003cto\u003eTove\u003c/to\u003e\n  \u003cfrom\u003eJani\u003c/from\u003e\n  \u003cheading\u003eReminder\u003c/heading\u003e\n  \u003cbody\u003eDon't forget me this weekend!\u003c/body\u003e\n\u003c/note\u003e\n`;\n\nconst doc = parse(xml); // Document\nconsole.log(doc.querySelectorAll('heading')); // NodeList\n```\n\nOptionally accepts second `mimeType` parameter (`\"text/xml\"` by default).\n\n```javascript\nconst svg = `\u003csvg xmlns=\"http://www.w3.org/2000/svg\" height=\"100\" width=\"100\" viewBox=\"0 0 100 100\"\u003e\n  \u003ccircle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"black\" stroke-width=\"3\" fill=\"red\" /\u003e\n\u003c/svg\u003e\n`;\n\nconst doc = parse(svg, 'image/svg+xml'); // Document\nconsole.log(doc.querySelectorAll('circle')); // NodeList\n```\n\n## Notes\n\n- Minimal size (bytes) in a browser since [DOMParser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser) is natively supported. Does not include any polyfills.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjs-bits%2Fdom-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjs-bits%2Fdom-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjs-bits%2Fdom-parser/lists"}