@@ -3,12 +3,15 @@ module XML
33using Mmap
44
55export
6- Node, LazyNode, # Core Types
7- children, parent, nodetype, tag, attributes, value, depth, next, prev, # interface
8- NodeConstructors # convenience functions for creating Nodes
6+ # Core Types:
7+ Node, LazyNode,
8+ # Interface:
9+ children, nodetype, tag, attributes, value,
10+ # Extended Interface for LazyNode:
11+ parent, depth, next, prev
912
1013# -----------------------------------------------------------------------------# escape/unescape
11- # only used by Text nodes
14+ # only used by Text nodes during `XML.write`
1215const escape_chars = (' &' => " &" , ' <' => " <" , ' >' => " >" , " '" => " '" , ' "' => " "" )
1316escape (x:: AbstractString ) = replace (x, escape_chars... )
1417unescape (x:: AbstractString ) = replace (x, reverse .(escape_chars)... )
@@ -24,6 +27,17 @@ unescape(x::AbstractString) = replace(x, reverse.(escape_chars)...)
2427 - CData # <![CData[...]]>
2528 - Element # <NAME attributes... > children... </NAME>
2629 - Text # text
30+
31+ NodeTypes can be used to construct XML.Nodes:
32+
33+ Document(children...)
34+ DTD(value)
35+ Declaration(; attributes)
36+ ProcessingInstruction(tag, attributes)
37+ Comment(text)
38+ CData(text)
39+ Element(tag, children...; attributes)
40+ Text(text)
2741"""
2842@enum (NodeType, CData, Comment, Declaration, Document, DTD, Element, ProcessingInstruction, Text)
2943
95109 Node(node::Node; kw...) # copy node with keyword overrides
96110 Node(node::LazyNode) # un-lazy the LazyNode
97111
98- A representation of an XML DOM node. For convenience constructors, see the `XML.NodeConstructors` module.
112+ A representation of an XML DOM node. For simpler construction, use `(::NodeType)(args...)`
99113"""
100114struct Node <: AbstractXMLNode
101115 nodetype:: NodeType
0 commit comments