Socket
Socket
Sign inDemoInstall

is-xml

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-xml

Check if a string is XML


Version published
Weekly downloads
277
decreased by-28.97%
Maintainers
1
Install size
3.19 kB
Created
Weekly downloads
 

Readme

Source

is-xml

Build Status NPM Downloads NPM Version License

Check if a String/Buffer is XML(HTML/XHTML/SVG/MathML/XUL/XBL/RSS)

Install

npm install --save is-xml

Usage

var isXML = require('is-xml');

XML

isXML('<message><warning>I am XML</warning></message>');
isXML(
    '<标题>一丝是谁?</标题>' +
    '<简介>当你们每天喊我「丝姐」的时候' +
    '我深深的沉浸在其中不能自拔</简介>'
);
// => true

HTML

isXML('<html>');
isXML('<html></html>');
isXML('<input type="text" />');
isXML('<img src="#" alt="img"/>');
// => true

SVG

isXML('<svg width="100" height="100" viewBox="0 0 30 30" version="1.1"></svg>');
isXML('<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg></svg>');
// => true

Emjio :joy:

isXML('<p class="foo_bar-🙈🔞🙈" id="👻">');
isXML('<p 😂👻😂="foo_bar">');
isXML('<foo😘( ●─● )💓></foo😘( ●─● )💓>');
isXML('<p class="(ོ•̀⌄•́)ོ"></p>');
// => true

More test case

License

MIT © yisibl (Weibo)

Keywords

FAQs

Last updated on 25 Sep 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc