forked from hgourvest/node-xml-lite
/
index.d.ts
40 lines (33 loc) · 1.06 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export const xtOpen: number;
export const xtClose: number;
export const xtAttribute: number;
export const xtText: number;
export const xtCData: number;
export const xtComment: number;
// Should match the exported values above
export const enum ParserEvent {
Open = 0,
Close = 1,
Attribute = 2,
Text = 3,
CData = 4,
Comment = 5
}
export type EventHandler = (event: ParserEvent, name?: string, value?: string) => boolean;
export interface XmlNode {
name: string;
attrs?: { [key: string]: string };
children?: (XmlNode | string)[];
}
export class XmlParser {
new(): XmlParser;
parseBuffer(buffer: Buffer, length: number, handler: EventHandler): boolean;
parseString(string: string, handler: EventHandler): boolean;
offset: number;
line: number;
col: number;
}
export function parseBuffer(buffer: Buffer): XmlNode;
export function parseString(string: string): XmlNode;
export function parseFile(path: string, callback: (err?: Error | null, root?: XmlNode) => void): void;
export function parseFileSync(path: string): XmlNode;