Skip to content

Commit d75b003

Browse files
committed
simplify the quick reference
1 parent 9953d11 commit d75b003

File tree

1 file changed

+31
-81
lines changed

1 file changed

+31
-81
lines changed

README.md

Lines changed: 31 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -63,101 +63,51 @@ end
6363
Quick reference
6464
---------------
6565

66+
See the [reference page](https://bicycle1885.github.io/EzXML.jl/latest/references.html) or docstrings for more details.
67+
6668
Types:
6769
* `Document`: an XML/HTML document
6870
* `Node`: an XML/HTML node including elements, attributes, texts, etc.
6971
* `XMLError`: an error happened in libxml2
72+
* `XMLReader`: a streaming XML reader
7073

7174
IO:
72-
* `read(Document, filename)`: read an XML/HTML document from a file.
73-
* `readxml(filename)`: read an XML document from file.
74-
* `readhtml(filename)`: read an HTML document from file.
75-
* `write(filename, doc)`: write a document to a file.
76-
* `parse(Document, string)`: parse an XML/HTML string.
77-
* `parsexml(string)`: parse an XML string.
78-
* `parsehtml(string)`: parse an HTML string.
79-
* `print(io, doc)`: print a document.
75+
* From file: `read(Document, filename)`, `readxml(filename)`, `readhtml(filename)`
76+
* From string or byte array: `parse(Document, string)`, `parsexml(string)`, `parsehtml(string)`
77+
* To file: `write(filename, doc)`
78+
* To stream: `print(io, doc)`
8079

8180
Accessors:
82-
* Node information:
83-
* `nodetype(node)`: return the type of a node.
84-
* `name(node)`: return the name of a node.
85-
* `content(node)`: return the content of a node.
86-
* `document(node)`: return the document of a node.
87-
* Attributes:
88-
* `node[name]`: return an attribute value of a node by name.
89-
* `node[name] = value`: set a value to an attribute of a node.
90-
* `haskey(node, name)`: return if a node has an attribute name.
91-
* `delete!(node, name)`: delete an attribute of a node.
92-
* Tree traversal:
93-
* `root(doc)`: return the root element of a document.
94-
* `firstnode(node)`: return the first child node of a node.
95-
* `lastnode(node)`: return the last child node of a node.
96-
* `firstelement(node)`: return the first child element of a node.
97-
* `lastelement(node)`: return the last child element of a node.
98-
* `nextnode(node)`: return the next node of a node.
99-
* `prevnode(node)`: return the previous node of a node.
100-
* `nextelement(node)`: return the next element of a node.
101-
* `prevelement(node)`: return the previous element of a node.
102-
* `parentnode(node)`: return the parent node of a node.
103-
* `parentelement(node)`: return the parent element of a node.
81+
* Node information: `nodetype(node)`, `name(node)`, `content(node)`
82+
* Document: `root(doc)`, `dtd(doc)`, `hasroot(doc)`, `hasdtd(doc)`, `setroot!(doc, element_node)`, `setdtd!(doc, dtd_node)`
83+
* Attributes: `node[name]`, `node[name] = value`, `haskey(node, name)`, `delete!(node, name)`
10484
* Node predicate:
105-
* `hasroot(doc)`: return if a document has a root element.
106-
* `hasdocument(node)`: return if a node has an associated document.
107-
* `hasnode(node)`: return if a node has a child node.
108-
* `haselement(node)`: return if a node has a child element.
109-
* `hasnextnode(node)`: return if a node has a next node.
110-
* `hasprevnode(node)`: return if a node has a previous node.
111-
* `hasnextelement(node)`: return if a node has a next element.
112-
* `hasprevelement(node)`: return if a node has a previous element.
113-
* `hasparentnode(node)`: return if a node has a parent node.
114-
* `hasparentelement(node)`: return if a node has a parent element.
115-
* `iselement(node)`: return if a node is an element node.
116-
* `isattribute(node)`: return if a node is an attribute node.
117-
* `istext(node)`: return if a node is a text node.
118-
* `iscdata(node)`: return if a node is a CDATA node.
119-
* `iscomment(node)`: return if a node is a comment node.
85+
* Document: `hasdocument(node)`
86+
* Parent: `hasparentnode(node)`, `hasparentelement(node)`
87+
* Child: `hasnode(node)`, `haselement(node)`
88+
* Sibling: `hasnextnode(node)`, `hasprevnode(node)`, `hasnextelement(node)`, `hasprevelement(node)`
89+
* Node type: `iselement(node)`, `isattribute(node)`, `EzXML.istext(node)`, `iscdata(node)`, `iscomment(node)`, `isdtd(node)`
90+
* Tree traversal:
91+
* Document: `document(node)`
92+
* Parent: `parentnode(node)`, `parentelement(node)`
93+
* Child: `firstnode(node)`, `lastnode(node)`, `firstelement(node)`, `lastelement(node)`
94+
* Sibling: `nextnode(node)`, `prevnode(node)`, `nextelement(node)`, `prevelement(node)`
95+
* Tree modifiers:
96+
* Link: `link!(parent_node, child_node)`, `linknext!(target_node, node)`, `linkprev!(target_node, node)`
97+
* Unlink: `unlink!(node)`
98+
* Create: `addelement!(parent_node, name, [content])`
12099
* Iterators:
121-
* `eachnode(node)`: create an iterator over child nodes.
122-
* `eachelement(node)`: create an iterator over child elements.
123-
* `eachattribute(node)`: create an iterator over attribute nodes.
124-
* `nodes(node)`: create a vector of child nodes.
125-
* `elements(node)`: create a vector of child elements.
126-
* `attributes(node)`: create a vector of attribute nodes.
127-
* Counters:
128-
* `countnodes(node)`: count the number of child nodes.
129-
* `countelements(node)`: count the number of child elements.
130-
* `countattributes(node)`: count the number of attributes.
131-
* Namespaces:
132-
* `namespace(node)`: return the namespace of a node.
133-
* `namespaces(node)`: create a vector of namespaces applying to a node.
100+
* Iterator: `eachnode(node)`, `eachelement(node)`, `eachattribute(node)`
101+
* Vector: `nodes(node)`, `elements(node)`, `attributes(node)`
102+
* Counters: `countnodes(node)`, `countelements(node)`, `countattributes(node)`
103+
* Namespaces: `namespace(node)`, `namespaces(node)`
134104

135105
Constructors:
136-
* `Document` type:
137-
* `XMLDocument(version="1.0")`: create an XML document.
138-
* `HTMLDocument(uri=nothing, externalID=nothing)`: create an HTML document.
139-
* `Node` type:
140-
* `XMLDocumentNode(version="1.0")`: create an XML document node.
141-
* `HTMLDocumentNode(uri, externalID)`: create an HTML document node.
142-
* `ElementNode(name)`: create an element node.
143-
* `TextNode(content)`: create a text node.
144-
* `CommentNode(content)`: create a comment node.
145-
* `CDataNode(content)`: create a CDATA node.
146-
* `AttributeNode(name, value)`: create an attribute node.
147-
148-
Modifiers:
149-
* `setroot!(doc, node)`: set the root element of a document to a node.
150-
* `link!(parent_node, child_node)`: add a child node to a parent node.
151-
* `linknext!(target_node, node)`: add a node next to a target node.
152-
* `linkprev!(target_node, node)`: add a node previous to a target node.
153-
* `unlink!(node)`: Unlink a node from its context (parent and siblings).
154-
* `addelement!(parent_node, name)`: add a child element with no content to a parent node.
155-
* `addelement!(parent_node, name, content)`: add a child element with content to a parent node.
106+
* `Document` type: `XMLDocument(version="1.0")`, `HTMLDocument(uri=nothing, externalID=nothing)`
107+
* `Node` type: `XMLDocumentNode(version="1.0")`, `HTMLDocumentNode(uri, externalID)`, `ElementNode(name)`, `TextNode(content)`, `CommentNode(content)`, `CDataNode(content)`, `AttributeNode(name, value)`, `DTDNode(name, [systemID, [externalID]])`
156108

157109
Queries:
158-
* `find(doc|node, xpath)`: find all nodes that match an XPath query.
159-
* `findfirst(doc|node, xpath)`: find the first matching node.
160-
* `findlast(doc|node, xpath)`: find the last matching node.
110+
* XPath: `find(doc|node, xpath)`, `findfirst(doc|node, xpath)`, `findlast(doc|node, xpath)`
161111

162112
Examples
163113
--------

0 commit comments

Comments
 (0)