Skip to content

๐Ÿš€ Is a fast XML parser in TypeScript with zero dependencies

License

Notifications You must be signed in to change notification settings

vitkarpov/fast-xml-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

48 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Fast-XML-parser

Is a fast XML parser in TypeScript with zero dependencies

CircleCI Code Style: Google

  • blazing fast โšก
  • zero dependencies ๐Ÿ“ฆ

Talk is cheap show me the code, or API overview

import {parse} from 'fast-xml-parser';

// Node { name: 'root', children: [
//   Node { name: 'html', children: [...]
// }] }
const root = parse('<!DOCTYPE html><html>hello</html>');

Parse returns a Node object, the root of the document tree. Node is an object with the following interface:

interface Node {
  type: TYPES;
  name: string;
  children?: Node[];
  attrs?: Record<string, string>;
}

You can manipulate the tree and serialize it back to HTML:

import {parse, stringify} from 'fast-xml-parser';

const root = parse('<!DOCTYPE html><html>hello</html>');

// change text node
root.children[1].children[0].name = 'hello, world!'

// <!DOCTYPE html><html>hello, world!</html>
console.log(stringify(root));

TBD: DOM API to manipulate the tree in a handy way

About

๐Ÿš€ Is a fast XML parser in TypeScript with zero dependencies

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published