UNPKG

3.36 kBMarkdownView Raw
1API
2===
3
4## Properties
5
6supported | name | description
7----------|-----|------------
8yes | domParser | instance of DOMParser
9yes | xmlSerializer | instance of XMLSerializer
10
11## Methods
12
13### Parsing/Serializing
14
15supported | name | alias | parameters | return value | description
16----------|------|-------|------------|--------------|------------
17yes | parse | parseFromString | String str | Document doc | parsing a xml string
18yes | serialize | serializeToString | Document doc | String str | Document to xml string
19
20### DOM maintaining
21
22supported | name | alias | parameters | return value | description
23----------|------|-------|------------|--------------|------------
24yes | attributesAsObject | | Node doc | Node child | attributes to key-value pairs
25yes | findChildNode | | Node doc, Object query | Node child | find one child node
26yes | findChildNodes | | Node doc, Object query | Array(Node) | find child nodes
27yes | findNodes | | Node doc, Object query | Array(Node) | find nodes
28yes | findOrCreateChildNode | | Node doc, Object query | Node child | find or create one child node
29yes | removeChildNode | | Node doc, Object query | Node child | remove one child node
30yes | eachChildNode | | Node doc, Object query, Function callback | null | execute callback using child node as parameter
31yes | eachNode | | Node doc, Object query, Function callback | null | execute callback using node as parameter
32
33#### Sample for `Object query`
34
35```javascript
36// query for <some-tag key="value"/>
37{
38 tagName: 'some-tag', // Node.tagName === 'some-tag'
39 nodeName: 'some-tag', // Node.nodeName === 'some-tag'
40 attributes: { // Node.getAttribute('key') === 'value'
41 key: 'value'
42 }
43}
44```
45
46### Formatting
47
48supported | name | alias | parameters | return value | description
49----------|------|-------|------------|--------------|------------
50yes | beautify | | String xml, (String or Number) step | String str | beautify xml string
51yes | uglify | | String xml, Boolean preserveComments | String str | uglify xml string
52yes | sanitize | | String xml, Boolean reverse | String str | escape or unescape "&", "<" and ">"
53
54### Converting
55
56supported | name | alias | parameters | return value | description
57----------|------|-------|------------|--------------|------------
58yes | dom2js | | Node node | Object obj | converting a Node instance into js object
59yes | xml2js | | String xml | Object obj | converting an xml string into js object
60yes | xml2json | | String xml, String replacer, String space | String json | converting an xml string into json string
61yes | js2xml | | Object obj, Object options | String xml | converting an object into xml string
62yes | json2xml | | String json, Object options | String xml | converting a json string into xml string
63yes | js2dom | | Object obj | Node doc | converting an object into a Node instance
64yes | json2dom | | String json | Node doc | converting a json string into a Node instance