8
8
9
9
This package offers fast data structures for reading and writing XML files with a consistent interface:
10
10
11
- #### Interface Core :
11
+ #### ` Node ` / ` LazyNode ` Interface :
12
12
13
- - ` nodetype(node) --> XML.NodeType ` (See ` ?XML.NodeType ` for details).
14
- - ` tag(node) --> String or Nothing `
15
- - ` attributes(node) --> OrderedDict{String,String} or Nothing `
16
- - ` value(node) --> String or Nothing `
17
- - ` children(node) --> Vector{typeof(node)} `
18
- - ` depth(node) --> Int `
13
+ - ` nodetype(node) → XML.NodeType ` (See ` ?XML.NodeType ` for details).
14
+ - ` tag(node) → String or Nothing `
15
+ - ` attributes(node) → Dict{String,String} or Nothing `
16
+ - ` value(node) → String or Nothing `
17
+ - ` children(node) → Vector{typeof(node)} `
19
18
20
- #### Interface for Lazy Data Structures:
21
- - ` next(node) --> typeof(node) `
22
- - ` prev(node) --> typeof(node) `
23
- - ` parent(node) --> typeof(node) `
19
+ #### Extended Interface for ` LazyNode `
20
+
21
+ - ` depth(node) → Int `
22
+ - ` next(node) → typeof(node) `
23
+ - ` prev(node) → typeof(node) `
24
+ - ` parent(node) → typeof(node) `
24
25
25
26
## Quickstart
26
27
@@ -29,11 +30,11 @@ using XML
29
30
30
31
filename = joinpath (dirname (pathof (XML)), " .." , " test" , " books.xml" )
31
32
32
- doc = XML . Node (filename)
33
+ doc = Node (filename)
33
34
34
35
children (doc)
35
36
# 2-element Vector{Node}:
36
- # Node DECLARATION <?xml version="1.0">
37
+ # Node DECLARATION <?xml version="1.0"? >
37
38
# Node ELEMENT <catalog> (12 children)
38
39
39
40
doc[end ] # The root node
@@ -43,11 +44,12 @@ doc[end][2] # Second child of root
43
44
# Node ELEMENT <book id="bk102"> (6 children)
44
45
```
45
46
46
- ## Data Structures
47
+ ## Node Types
47
48
48
49
### ` XML.Node `
50
+
49
51
- An eager data structure that loads the entire XML DOM in memory.
50
- - ** This is what you should use to build an XML document programmatically.**
52
+ - ** This is what you would use to build an XML document programmatically.**
51
53
- ` Node ` s have some additional methods that aid in construction/mutation:
52
54
53
55
``` julia
@@ -56,15 +58,6 @@ push!(parent::Node, child::Node)
56
58
57
59
# Replace a child:
58
60
parent[2 ] = child
59
-
60
- # Create a new node with an edited field. `kw...` can be one or more of:
61
- # - nodetype::NodeType
62
- # - tag (String or Nothing)
63
- # - attributes (OrderedDict{String,String} or Nothing)
64
- # - value (String or Nothing)
65
- # - children (Vector{Node} or nothing),
66
- # - depth::Int (this will be automatically set if not provided)
67
- Node (node; kw... )
68
61
```
69
62
70
63
- Bring convenience functions into your namespace with ` using XML.NodeConstructors ` :
0 commit comments