Detector plugin for file-type for XML files.
npm install @file-type/xml
The following example shows how add the XML detector to file-type.
import {NodeFileTypeParser} from 'file-type';
import {detectXml} from '@file-type/xml';
const parser = new NodeFileTypeParser({customDetectors: [detectXml]});
const fileType = await parser.fromFile('example.kml');
console.log(fileType);
You can also use the XML detector outside file-type:
import {XmlTextDetector} from 'index.js';
xmlTextDetector.write('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');
const fileType = xmlTextDetector.fileType;
console.log(JSON.stringify(fileType)); // Outputs: {"ext":"svg","mime":"image/svg+xml"}
- XML (default for XML, unless more specific format was detected)
- GML (Geography Markup Language)
- KML (Keyhole Markup Language)
- MusicXML, Uncompressed
- RSS (RDF Site Summary or Really Simple Syndication)
- SVG: (Scalable Vector Graphics)
- XHTML