1.1.0 • Published 8 years ago

xml-escape v1.1.0

Weekly downloads
160,607
License
MIT License
Repository
github
Last release
8 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

cordova-ios@everything-registry/sub-chunk-3186gulp-qunit-puppeteerjira-todojmdict-parserhexo-generator-patcasthexo-generator-podcasthexo-generator-podcastshexo-generator-podcasts-2hexo-generator-podxiaoyuujs2flowchartjsxapihornet-js-builder-newlsxpathgimonfuhackmyapihackmycorehackmyresumeinfosmsmaximodev-cliep_xmlexporteslint-browserifyeslint-jenkinsembedded-tselectron-windows-notificationselectron-windows-notifications-rs3electron-windows-notifications-rs4express-riotgatsby-plugin-opensearchexpress-chocolatey-serverfluentcvooxml-signature-pagespa-appcore-iososm-object-streamodb2graphmlpencil-mustachenativescript-cloudndmnativescript-angular-clinativescript-javascript-clipinganappcoremocha-sonarqube-reportermns-node-sdkmocha-qube-reporterprofoundjsqunit-puppeteer-runnerquasar-app-extension-ide-helperscrewdriver-executor-jenkinsscriptless-clisamlifyreapacktc-clitc-cli-majdy@dcarretastk/tkcreatedataobjects@dcarretastk/tkloadtpasvg-text-utilsvg-labelssmartfacestrxmlstrxml-esstrictersmartsmssoxsot-formattextlint-formattertokml-estest-recordingsurf-build@pschm/report-mapper@pruner/clizotero-libzstreams-xml-writerz2g@qdabra/build-xmlveritatiset@mibuilder/cli@paulpopat/sote@seleniumhq/side-migrate@kalopilato/hackmyresume@infinitebrahmanuniverse/nolb-xm4z-upnp@adobe/helix-pingdom-status@wedgekit/wedgecop@cdevine49/react-numeric-input@bpowers_dmsi/wedgecop@xtp-smart/electron-windows-notifications@ssh/audiosalad-xml@skodaflow/cypress-execution-sonar-reporter@apigrate/highrise@atomictech/xlsx-write-stream@archi-lab/report-mapperadapter-filters@zenml/zenmlallbirds-apis@divekit/report-mapperapelcoud-samlifychocobi-ioscom.meenrios.samplecomic-dlcodeless-clicr2checkstyle
1.1.0

8 years ago

1.0.0

10 years ago