An open API service indexing awesome lists of open source software.

https://github.com/borewit/file-type-xml

Detector plugin for file-type for XML files
https://github.com/borewit/file-type-xml

detection detector file-type kml svg xml

Last synced: 4 months ago
JSON representation

Detector plugin for file-type for XML files

Awesome Lists containing this project

README

          

[![NPM version](https://img.shields.io/npm/v/@file-type/xml.svg)](https://npmjs.org/package/@file-type/xml)
[![Node.js CI](https://github.com/Borewit/file-type-xml/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/Borewit/file-type-xml/actions/workflows/nodejs-ci.yml)
[![npm downloads](http://img.shields.io/npm/dm/@file-type/xml.svg)](https://npmcharts.com/compare/@file-type/xml?start=365)

# @file-type/xml

Detector plugin for [file-type](https://github.com/sindresorhus/file-type) for XML files.

## Installation

```bash
npm install @file-type/xml
```

## Usage

The following example shows how to add the XML detector to [file-type](https://github.com/sindresorhus/file-type).
```js
import {FileTypeParser} from 'file-type';
import {detectXml} from '@file-type/xml';

const parser = new FileTypeParser({customDetectors: [detectXml]});
const fileType = await parser.fromFile('example.kml');
console.log(fileType);
```

You can also use the XML detector outside [file-type](https://github.com/sindresorhus/file-type):
```js
import {XmlTextDetector} from '@file-type/xml';

const xmlTextDetector = new XmlTextDetector();
xmlTextDetector.write('');
const fileType = xmlTextDetector.fileType;
console.log(JSON.stringify(fileType)); // Outputs: {"ext":"svg","mime":"image/svg+xml"}
```

## Support file formats

- [XML](https://en.wikipedia.org/wiki/XML) (default for XML, unless a more specific format was detected)
- [Apple Property list, `.plist`](https://en.wikipedia.org/wiki/Property_list)
- [Atom]()
- [DocBook](https://en.wikipedia.org/wiki/DocBook)
- [GML (Geography Markup Language)](https://en.wikipedia.org/wiki/Geography_Markup_Language)
- [GPX (GPS Exchange Format)](https://en.wikipedia.org/wiki/GPS_Exchange_Format)
- [KML (Keyhole Markup Language)](https://en.wikipedia.org/wiki/Keyhole_Markup_Language)
- [MathML (Mathematical Markup Language)](https://en.wikipedia.org/wiki/MathML)
- [MusicXML, Uncompressed](https://en.wikipedia.org/wiki/MusicXML)
- [OPML (Outline Processor Markup Language)](https://en.wikipedia.org/wiki/OPML)
- [RSS (RDF Site Summary or Really Simple Syndication)](https://en.wikipedia.org/wiki/RSS)
- [SMIL: (Synchronized Multimedia Integration Language)](https://en.wikipedia.org/wiki/Synchronized_Multimedia_Integration_Language)
- [SVG: (Scalable Vector Graphics)](https://en.wikipedia.org/wiki/SVG)
- [TEI, Text Encoding Initiative](https://en.wikipedia.org/wiki/Text_Encoding_Initiative)
- [TTML: (Timed Text Markup Language)](https://en.wikipedia.org/wiki/Timed_Text_Markup_Language)
- [X3D (Extensible 3D)](https://en.wikipedia.org/wiki/X3D)
- [XHTML](https://en.wikipedia.org/wiki/XHTML)
- [XLIFF (XML Localization Interchange File Format)](https://en.wikipedia.org/wiki/XLIFF)

## Licence

This project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.