Skip to content

Commit 38e20fa

Browse files
authored
Add quick example to README
Added a quick example of parsing an XML file using the TypesXML library.
1 parent 893ea72 commit 38e20fa

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ TypesXML is a TypeScript / Node.js XML library for parsing, validating, and proc
88

99
The library is implemented entirely in TypeScript (no native bindings) and is validated against the official W3C XML test suites for DTD and XML Schema.
1010

11+
## Quick example
12+
13+
Parse an XML file and build a DOM document:
14+
15+
```ts id="9w3k2x"
16+
import { DOMBuilder, SAXParser } from "typesxml";
17+
18+
const handler = new DOMBuilder();
19+
const parser = new SAXParser();
20+
21+
parser.setContentHandler(handler);
22+
parser.parseFile("example.xml");
23+
24+
const document = handler.getDocument();
25+
console.log(document.toString());
26+
```
27+
1128
## Features
1229

1330
- DOM builder (`DOMBuilder`) that produces an in-memory tree and preserves lexical information needed by canonicalization.

0 commit comments

Comments
 (0)