Reference
Types
EzXML.Document — TypeAn XML/HTML document type.
EzXML.Node — TypeA proxy type to libxml2's node struct.
Properties
| Name | Type | Description |
|---|---|---|
type | EzXML.NodeType | the type of a node |
name | String? | the name of a node |
path | String | the absolute path to a node |
content | String | the content of a node |
namespace | String? | the namespace associated with a node |
EzXML.StreamReader — TypeA streaming XML reader type.
EzXML.XMLError — TypeAn error detected by libxml2.
I/O
EzXML.parsexml — Functionparsexml(xmlstring; options...)Parse xmlstring and create an XML document.
Parsing Options
noerror = false: suppress (recoverable) error reportsnowarning = false: suppress warning reportspedantic = false: pedantic error reportingnoblanks = false: remove blank nodes
EzXML.parsehtml — Functionparsehtml(htmlstring; options...)Parse htmlstring and create an HTML document.
See parsexml for parsing options.
EzXML.readxml — Functionreadxml(filename; options...)Read filename and create an XML document.
See parsexml for parsing options.
readxml(input::IO; options...)Read input and create an XML document.
See parsexml for parsing options.
EzXML.readhtml — Functionreadhtml(filename; options...)Read filename and create an HTML document.
See parsexml for parsing options.
readhtml(input::IO; options...)Read input and create an HTML document.
See parsexml for parsing options.
EzXML.prettyprint — Functionprettyprint([io], node::Node)Print node with formatting.
prettyprint([io], doc::Document)Print doc with formatting.
Constructors
EzXML.XMLDocument — FunctionXMLDocument(version="1.0")Create an XML document.
EzXML.HTMLDocument — FunctionHTMLDocument(uri=nothing, externalID=nothing)Create an HTML document.
EzXML.XMLDocumentNode — FunctionXMLDocumentNode(version)Create an XML document node with version.
EzXML.HTMLDocumentNode — FunctionHTMLDocumentNode(uri, externalID)Create an HTML document node.
uri and externalID are either a string or nothing.
EzXML.ElementNode — FunctionElementNode(name)Create an element node with name.
EzXML.TextNode — FunctionTextNode(content)Create a text node with content.
EzXML.CommentNode — FunctionCommentNode(content)Create a comment node with content.
EzXML.CDataNode — FunctionCDataNode(content)Create a CDATA node with content.
EzXML.AttributeNode — FunctionAttributeNode(name, value)Create an attribute node with name and value.
EzXML.DTDNode — FunctionDTDNode(name, [systemID, [externalID]])Create a DTD node with name, systemID, and externalID.
Node types
| Node type | Integer |
|---|---|
EzXML.ELEMENT_NODE | 1 |
EzXML.ATTRIBUTE_NODE | 2 |
EzXML.TEXT_NODE | 3 |
EzXML.CDATA_SECTION_NODE | 4 |
EzXML.ENTITY_REF_NODE | 5 |
EzXML.ENTITY_NODE | 6 |
EzXML.PI_NODE | 7 |
EzXML.COMMENT_NODE | 8 |
EzXML.DOCUMENT_NODE | 9 |
EzXML.DOCUMENT_TYPE_NODE | 10 |
EzXML.DOCUMENT_FRAG_NODE | 11 |
EzXML.NOTATION_NODE | 12 |
EzXML.HTML_DOCUMENT_NODE | 13 |
EzXML.DTD_NODE | 14 |
EzXML.ELEMENT_DECL | 15 |
EzXML.ATTRIBUTE_DECL | 16 |
EzXML.ENTITY_DECL | 17 |
EzXML.NAMESPACE_DECL | 18 |
EzXML.XINCLUDE_START | 19 |
EzXML.XINCLUDE_END | 20 |
EzXML.DOCB_DOCUMENT_NODE | 21 |
Node accessors
EzXML.nodetype — Methodnodetype(node::Node)Return the type of node as an integer.
EzXML.nodepath — Methodnodepath(node::Node)Return the path of node.
EzXML.nodename — Methodnodename(node::Node)Return the node name of node.
EzXML.nodecontent — Methodnodecontent(node::Node)Return the node content of node.
EzXML.namespace — Methodnamespace(node::Node)Return the namespace associated with node.
EzXML.namespaces — Methodnamespaces(node::Node)Create a vector of namespaces applying to node.
EzXML.hasnodename — Methodhasnodename(node::Node)Return if node has a node name.
EzXML.hasnamespace — Methodhasnamespace(node::Node)Return if node is associated with a namespace.
EzXML.iselement — Methodiselement(node::Node)Return if node is an element node.
EzXML.isattribute — Methodisattribute(node::Node)Return if node is an attribute node.
EzXML.istext — Methodistext(node::Node)Return if node is a text node.
EzXML.iscdata — Methodiscdata(node::Node)Return if node is a CDATA node.
EzXML.iscomment — Methodiscomment(node::Node)Return if node is a comment node.
EzXML.isdtd — Methodisdtd(node::Node)Return if node is a DTD node.
EzXML.countnodes — Methodcountnodes(parent::Node)Count the number of child nodes of parent.
EzXML.countelements — Methodcountelements(parent::Node)Count the number of child elements of parent.
EzXML.countattributes — Methodcountattributes(elem::Node)Count the number of attributes of elem.
EzXML.systemID — MethodsystemID(node::Node)Return the system ID of node.
EzXML.externalID — MethodexternalID(node::Node)Return the external ID of node.
Node modifiers
EzXML.setnodename! — Methodsetnodename!(node::Node, name::AbstractString)Set the name of node.
EzXML.setnodecontent! — Methodsetnodecontent!(node::Node, content::AbstractString)Replace the content of node.
Document properties
EzXML.version — Functionversion(doc::Document)Return the version string of doc.
EzXML.encoding — Functionencoding(doc::Document)Return the encoding string of doc.
EzXML.hasversion — Functionhasversion(doc::Document)Return if doc has a version string.
EzXML.hasencoding — Functionhasencoding(doc::Document)Return if doc has an encoding string.
DOM tree accessors
EzXML.document — Functiondocument(node::Node)Return the document of node.
EzXML.root — Functionroot(doc::Document)Return the root element of doc.
EzXML.dtd — Functiondtd(doc::Document)Return the DTD node of doc.
EzXML.parentnode — Functionparentnode(node::Node)Return the parent of node.
EzXML.parentelement — Functionparentelement(node::Node)Return the parent element of node.
EzXML.firstnode — Functionfirstnode(node::Node)Return the first child node of node.
EzXML.lastnode — Functionlastnode(node::Node)Return the last child node of node.
EzXML.firstelement — Functionfirstelement(node::Node)Return the first child element of node.
EzXML.lastelement — Functionlastelement(node::Node)Return the last child element of node.
EzXML.nextnode — Functionnextnode(node::Node)Return the next node of node.
EzXML.prevnode — Functionprevnode(node::Node)Return the previous node of node.
EzXML.nextelement — Functionnextelement(node::Node)Return the next element of node.
EzXML.prevelement — Functionprevelement(node::Node)Return the previous element of node.
EzXML.eachnode — Functioneachnode(node::Node, [backward=false])Create an iterator of child nodes.
EzXML.nodes — Functionnodes(node::Node, [backward=false])Create a vector of child nodes.
EzXML.eachelement — Functioneachelement(node::Node, [backward=false])Create an iterator of child elements.
EzXML.elements — Functionelements(node::Node, [backward=false])Create a vector of child elements.
EzXML.eachattribute — Functioneachattribute(node::Node)Create an iterator of attributes.
eachattribute(reader::StreamReader)Return an AttributeReader object for the current node of reader
EzXML.attributes — Functionattributes(node::Node)Create a vector of attributes.
EzXML.hasroot — Functionhasroot(doc::Document)Return if doc has a root element.
EzXML.hasdtd — Functionhasdtd(doc::Document)Return if doc has a DTD node.
EzXML.hasnode — Functionhasnode(node::Node)Return if node has a child node.
EzXML.hasnextnode — Functionhasnextnode(node::Node)Return if node has a next node.
EzXML.hasprevnode — Functionhasprevnode(node::Node)Return if node has a previous node.
EzXML.haselement — Functionhaselement(node::Node)Return if node has a child element.
EzXML.hasnextelement — Functionhasnextelement(node::Node)Return if node has a next node.
EzXML.hasprevelement — Functionhasprevelement(node::Node)Return if node has a previous node.
EzXML.hasdocument — Functionhasdocument(node::Node)Return if node belongs to a document.
EzXML.hasparentnode — Functionhasparentnode(node::Node)Return if node has a parent node.
EzXML.hasparentelement — Functionhasparentelement(node::Node)Return if node has a parent node.
DOM tree modifiers
EzXML.setroot! — Functionsetroot!(doc::Document, node::Node)Set the root element of doc to node and return the root element.
EzXML.setdtd! — Functionsetdtd!(doc::Document, node::Node)Set the DTD node of doc to node and return the DTD node.
EzXML.link! — Functionlink!(parent::Node, child::Node)Link child at the end of children of parent.
EzXML.linknext! — Functionlinknext!(target::Node, node::Node)Link node as the next sibling of target.
EzXML.linkprev! — Functionlinkprev!(target::Node, node::Node)Link node as the prev sibling of target.
EzXML.unlink! — Functionunlink!(node::Node)Unlink node from its context.
EzXML.addelement! — Functionaddelement!(parent::Node, name::AbstractString)Add a new child element of name with no content to parent and return the new child element.
addelement!(parent::Node, name::AbstractString, content::AbstractString)Add a new child element of name with content to parent and return the new child element.
XPath query
Base.findall — Methodfindall(xpath::AbstractString, doc::Document)Find nodes matching xpath XPath query from doc.
Base.findfirst — Methodfindfirst(xpath::AbstractString, doc::Document)Find the first node matching xpath XPath query from doc.
Base.findlast — Methodfindlast(doc::Document, xpath::AbstractString)Find the last node matching xpath XPath query from doc.
Base.findall — Methodfindall(xpath::AbstractString, node::Node, [ns=namespaces(node)])Find nodes matching xpath XPath query starting from node.
The ns argument is an iterator of namespace prefix and URI pairs.
Base.findfirst — Methodfindfirst(xpath::AbstractString, node::Node, [ns=namespaces(node)])Find the first node matching xpath XPath query starting from node.
Base.findlast — Methodfindlast(node::Node, xpath::AbstractString, [ns=namespaces(node)])Find the last node matching xpath XPath query starting from node.
Validation
EzXML.validate — Functionvalidate(doc::Document, [dtd::Node])Validate doc against dtd and return the validation log.
The validation log is empty if and only if doc is valid. The DTD node in doc will be used if dtd is not passed.
EzXML.readdtd — Functionreaddtd(filename::AbstractString)Read filename and create a DTD node.
Reader node types
| Node type | Integer |
|---|---|
EzXML.READER_NONE | 0 |
EzXML.READER_ELEMENT | 1 |
EzXML.READER_ATTRIBUTE | 2 |
EzXML.READER_TEXT | 3 |
EzXML.READER_CDATA | 4 |
EzXML.READER_ENTITY_REFERENCE | 5 |
EzXML.READER_ENTITY | 6 |
EzXML.READER_PROCESSING_INSTRUCTION | 7 |
EzXML.READER_COMMENT | 8 |
EzXML.READER_DOCUMENT | 9 |
EzXML.READER_DOCUMENT_TYPE | 10 |
EzXML.READER_DOCUMENT_FRAGMENT | 11 |
EzXML.READER_NOTATION | 12 |
EzXML.READER_WHITESPACE | 13 |
EzXML.READER_SIGNIFICANT_WHITESPACE | 14 |
EzXML.READER_END_ELEMENT | 15 |
EzXML.READER_END_ENTITY | 16 |
EzXML.READER_XML_DECLARATION | 17 |
Streaming reader
EzXML.expandtree — Methodexpandtree(reader::StreamReader)Expand the current node of reader into a full subtree that will be available until the next read of node.
Note that the expanded subtree is a read-only and temporary object. You cannot modify it or keep references to any nodes of it after reading the next node.
Currently, namespace functions and XPath query will not work on the expanded subtree.
EzXML.nodetype — Methodnodetype(reader::StreamReader)Return the type of the current node of reader.
EzXML.nodename — Methodnodename(reader::StreamReader)Return the name of the current node of reader.
EzXML.nodecontent — Methodnodecontent(reader::StreamReader)Return the content of the current node of reader.
EzXML.nodedepth — Methodnodedepth(reader::StreamReader)Return the depth of the current node of reader.
EzXML.namespace — Methodnamespace(reader::StreamReader)Return the namespace of the current node of reader.
EzXML.hasnodecontent — Methodhasnodecontent(reader::StreamReader)Return if the current node of reader has content.
EzXML.hasnodename — Methodhasnodename(reader::StreamReader)Return if the current node of reader has a node name.