JSPM

is-xml

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1389
  • Score
    100M100P100Q119330F
  • License MIT

Check if a string is XML

Package Exports

  • is-xml

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-xml) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 😂

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)