Socket
Socket
Sign inDemoInstall

xml-escape

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml-escape

Escape XML


Version published
Weekly downloads
194K
decreased by-2.13%
Maintainers
1
Weekly downloads
 
Created

What is xml-escape?

The xml-escape npm package is a utility for escaping XML entities in strings. It is useful for ensuring that special characters in XML content are properly escaped to avoid parsing errors or injection attacks.

What are xml-escape's main functionalities?

Basic XML Escaping

This feature allows you to escape special XML characters such as &, <, >, ", and '. The code sample demonstrates how to use the xml-escape package to escape a string containing special XML characters.

const xmlEscape = require('xml-escape');
const escapedString = xmlEscape('This is a test & only a test <test>');
console.log(escapedString); // Output: This is a test &amp; only a test &lt;test&gt;

Custom Escaping

This feature allows you to define custom escape sequences for specific characters. The code sample demonstrates how to use the xml-escape package to escape a string with custom escape sequences for &, <, and >.

const xmlEscape = require('xml-escape');
const customEscapedString = xmlEscape('This is a test & only a test <test>', {
  '&': '&customAmp;',
  '<': '&customLt;',
  '>': '&customGt;'
});
console.log(customEscapedString); // Output: This is a test &customAmp; only a test &customLt;test&customGt;

Other packages similar to xml-escape

Keywords

FAQs

Package last updated on 14 Mar 2016

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc