1.1.0 • Published 9 years ago

xml-escape v1.1.0

Weekly downloads
160,607
License
MIT License
Repository
github
Last release
9 years ago

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

@everything-registry/sub-chunk-3186tc-clitc-cli-majdysvg-labelstest-recordingsvg-text-utiltextlint-formatter@divekit/report-mapper@bpowers_dmsi/wedgecopjira-todojsxapijmdict-parserjs2flowchartstricterstrxml-esstrxmlsurf-buildsoxsot-formattokml-es@apigrate/highrise@archi-lab/report-mapper@atomictech/xlsx-write-stream@adobe/helix-pingdom-status@cdevine49/react-numeric-input4z-upnp@dcarretastk/tkcreatedataobjects@dcarretastk/tkloadtpaz2gzstreams-xml-writerzotero-libveritatiset@hubbo/next@infinitebrahmanuniverse/nolb-xm@mibuilder/cli@kalopilato/hackmyresume@qdabra/build-xml@pschm/report-mapper@pruner/cli@paulpopat/sote@skodaflow/cypress-execution-sonar-reporter@seleniumhq/side-migrate@ssh/audiosalad-xmlmocha-sonarqube-reportermocha-qube-reportermns-node-sdknativescript-angular-clinativescript-javascript-clinativescript-cloudndmpa-appcore-iososm-object-streamosv2gitlabooxml-signature-pagesodb2graphmlscrewdriver-executor-jenkinssamlifyquasar-app-extension-ide-helperscriptless-clipencil-mustachepinganappcorequnit-puppeteer-runnerreapackprofoundjssmartsmssmartfacegimonfuinfosmsgulp-qunit-puppeteerhornet-js-builder-newhexo-generator-podcasthexo-generator-podcastshexo-generator-podcasts-2hexo-generator-patcasthexo-generator-podxiaoyuuhackmyapihackmycorehackmyresumelsxpathmaximodev-cli@wedgekit/wedgecop@xtp-smart/electron-windows-notifications@xwiki/cristal-link-suggest-nextcloud@zenml/zenml@tapni/samlifyallbirds-apisadapter-filtersapelcoud-samlifychocobi-ioscheckstyle-formattercomic-dlcom.meenrios.samplecodeless-clicrmfetchkitcr2checkstylecordova-ios-devdev-sqsdocx-templateelectron-windows-notificationselectron-windows-notifications-rs3electron-windows-notifications-rs4
1.1.0

9 years ago

1.0.0

11 years ago