xml-escape
Escape XML
Last updated 9 years ago by mhernandez .
MIT License · Repository · Bugs · Original npm · Tarball · package.json
$ npm install xml-escape 
SYNC missed versions from official npm registry.

xml-escape

Escape XML in javascript (NodeJS)

npm install xml-escape

// Warning escape is a reserved word, so maybe best to use xmlescape for var name
var xmlescape = require('xml-escape');

xmlescape('"hello" \'world\' & false < true > -1');

// output
// '&quot;hello&quot; &apos;world&apos; &amp; false &lt; true &gt; -1'

// don't escape some characters
xmlescape('"hello" \'world\' & false < true > -1', '>"&')

// output
// '"hello" &apos;world&apos; & false &lt; true > -1'

There is also now an ignore function thanks to @jayflo

esc = require('./');

ignore = '"<&'
// note you should never ignore an &
output = esc('I am "<&not>" escaped', ignore)
console.log(output)

//I am "<&not&gt;" escaped

Bitdeli Badge

Current Tags

  • 1.1.0                                ...           latest (9 years ago)

2 Versions

  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE