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