Socket
Book a DemoInstallSign in
Socket

xml-integrity

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

xml-integrity

XML parser that 100% retains all formatting for creating identical XML on roundtrips

0.0.1
unpublished
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

xml-integrity

Typescript XML parser that 100% retains all formatting for creating identical XML on roundtrips.

If you have an XML file that you want to read, modify, and write back, this library will ensure that the output XML is formatted identical to the input XML.

Features

  • Retains all whitespace and line endings
  • Retains all comments
  • Retains whether an element is self-closing or not
  • Retains attributes in the order they were defined
  • Retains attribute quotes (single or double) and whitespace before and after the attribute name
  • Retains XML processing instructions (including the XML declaration)
  • Retains CDATA sections

Example

The following XML:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <!-- my comment -->
  <element attribute="value" />
  <element attribute='value'></element>
</root>

Will get parsed by XmlParser.parse(..) to:

new XmlDocument([
  new XmlProcessing('xml',' ', 'version="1.0" encoding="UTF-8"'),
  new XmlText('\n'),
  new XmlElement('root', [], [
    new XmlText('\n  '),
    new XmlComment(' my comment '),
    new XmlText('\n  '),
    new XmlElement('element', [new XmlAttribute('attribute', 'value')], [], ' ', true),
    new XmlText('\n  '),
    new XmlElement('element', [new XmlAttribute('attribute', 'value', ' ', '', '', "'")], [], '', false),
    new XmlText('\n')
  ])
]);

Development

This project is written in Typescript and uses Bun.

bun install
bun test

Keywords

XML

FAQs

Package last updated on 26 Feb 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.