
Product
Introducing Module Reachability: Focus on the Vulnerabilities That Matter
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
**A no-dependency XML parser with DOM-like AST and XML serialization for node.js and the browser.**
A no-dependency XML parser with DOM-like AST and XML serialization for node.js and the browser.
tsxml is a small, not (yet) spec compliant XML library that contains a liberal parser, a syntax tree similar to, but not as complicated as, the DOM. The syntax tree can be used to build XML manually. It can serialize formatted and compact XML.
It supports all kinds of XML nodes, including comments, markup declaration openers (such as <!DOCTYPE ...>
), processing instructions (<?svg...
) and self closing (<foo />
) and "void" (<foo>
) nodes, meaning it's capable of parsing HTML and SVG, too.
Yup, here: vs-code-xml-format.
The parser is:
The parser is not (yet):
At the moment the parser only processes complete XML strings at once, incremental parsing is not possible yet (which can be a performance issue with huge documents). If you need incremental parsing and are comfortable with using streams, check out sax-js.
Does not exist. At least not yet.
The syntax tree can be built manually (see examples) or by the parser. It is similar to the DOM, but not quite as complex. It can be used to traverse (in fact, the parser uses AST nodes it creates to traverse while parsing) and to serialize XML.
To-Do-List:
Syntax tree nodes support XML serialization with their toString()
and toFormattedString()
methods, for example:
const document = xml.Compiler.parseStringToAst(`
<foo><bar /></foo>
`);
/*
The following 2 statements will log '<foo><bar /></foo>'
*/
console.log(node.toString());
console.log(node + '');
/*
The following statement will log:
<foo>
<bar />
</foo>
*/
node.toFormattedString();
Formatting can also be done in a somewhat more concise way:
console.log(await xml.Compiler.formatXmlString('<foo><bar /></foo>'));
/*
...which will log:
<foo>
<bar />
</foo>
*/
I see your point. There's plenty of good parsers around and most of them get the job done alright. What I wanted, however, is a tool that runs in every environment (browser, node.js, you name it), doesn't come with a myriad of dependencies (especially ones that run in node's C-space), that doesn't just ignore comments, MDOs and processing instructions (which are a huge no-no in some other libraries) and that, ideally, has a syntax tree that allows traversal similar to the DOM instead of just providing plain old objects. Oh, right, there should be a way to serialize XML as well.
If you don't need all of this, you might want to check out these:
MIT. See LICENSE file.
FAQs
**A no-dependency XML parser with DOM-like AST and XML serialization for node.js and the browser.**
The npm package tsxml receives a total of 53 weekly downloads. As such, tsxml popularity was classified as not popular.
We found that tsxml demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Company News
Socket is bringing best-in-class reachability analysis into the platform — cutting false positives, accelerating triage, and cementing our place as the leader in software supply chain security.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.