Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 8, 2024 via pnpm

xmldom 0.6.0

A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.
Package summary
Share
4
issues
2
critical severity
vulnerability
2
2
moderate severity
vulnerability
2
1
license
1
MIT
Package created
6 Jan 2012
Version published
17 Apr 2021
Maintainers
2
Total deps
1
Direct deps
0
License
MIT

Issues

4

2 critical severity issues

critical
Recommendation: None
via: xmldom@0.6.0
Recommendation: None
via: xmldom@0.6.0
Collapse
Expand

2 moderate severity issues

moderate
Recommendation: None
via: xmldom@0.6.0
Recommendation: None
via: xmldom@0.6.0
Collapse
Expand

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
xmldom@0.6.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of xmldom 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does xmldom do?

XMLDOM is a JavaScript-based module that adheres to the W3C standard. It primarily implements the DOMParser and XMLSerializer interface in a similar way as in the browser. This makes it an ideal solution for manipulating XML documents within various JavaScript environments, such as Node.js, Rhino, and others. The functionality provided by the xmldom package ranges from basic operations like parsing an XML string into an XML Document object (DOM), modifying that document, and then serializing it back into an XML string. By achieving full compatibility with W3C's DOM level 2, and some compatibility with level 3, xmldom ensures adherence to standardized practices for XML document handling.

How do you use xmldom?

To use xmldom in your JavaScript project, first, you need to install it using npm, as shown below:

npm install xmldom

Then, you can import the package and use it in your code. Here's an example of how you can parse an XML string into a DOM and then work with it:

const { DOMParser } = require('xmldom');

const doc = new DOMParser().parseFromString(
    '<xml xmlns="a" xmlns:c="./lite">\n' +
        '\t<child>test</child>\n' +
        '\t<child></child>\n' +
        '\t<child/>\n' +
        '</xml>',
    'text/xml'
);
doc.documentElement.setAttribute('x', 'y');
doc.documentElement.setAttributeNS('./lite', 'c:x', 'y2');
console.info(doc);

const nsAttr = doc.documentElement.getAttributeNS('./lite', 'x');
console.info(nsAttr);

You can also serialize an XML document back into a string using the XMLSerializer:

const { DOMParser, XMLSerializer } = require('xmldom');

const doc = new DOMParser().parseFromString('<root/>', 'text/xml');
const serializer = new XMLSerializer();
const xmlStr = serializer.serializeToString(doc);
console.info(xmlStr); // logs: <root/>

These examples show basic usage, but xmldom provides a full suite of methods for interacting with XML documents, including methods for CRUD operations on XML nodes, handling XML namespaces, dealing with XML errors, and more.

Where are the xmldom docs?

The documentation for xmldom is available both directly within the npm package details page and on the GitHub repository. The docs detail the API reference, including the DOMParser and XMLSerializer interfaces, as well as other aspects like DOM level 2 methods and attributes, DOM level 3 support, and exceptions. The xmldom documentation is a comprehensive guide that assists users with different levels of XML manipulation, providing both conceptual understanding and practical usage examples.