You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

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

1.1.0
latest
Source
npm
Version published
Weekly downloads
344K
-25.7%
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

Escape

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