is-xml
v0.1.0
Published
Check if a string is XML
Downloads
3,201
Maintainers
Readme
is-xml
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