Reference

Types

EzXML.NodeType

A proxy type to libxml2's node struct.

Properties

NameTypeDescription
typeEzXML.NodeTypethe type of a node
nameString?the name of a node
pathStringthe absolute path to a node
contentStringthe content of a node
namespaceString?the namespace associated with a node

I/O

EzXML.parsexmlFunction
parsexml(xmlstring)

Parse xmlstring and create an XML document.

EzXML.parsehtmlFunction
parsehtml(htmlstring)

Parse htmlstring and create an HTML document.

EzXML.readxmlFunction
readxml(filename)

Read filename and create an XML document.

readxml(input::IO)

Read input and create an XML document.

EzXML.readhtmlFunction
readhtml(filename)

Read filename and create an HTML document.

readhtml(input::IO)

Read input and create an HTML document.

EzXML.prettyprintFunction
prettyprint([io], node::Node)

Print node with formatting.

prettyprint([io], doc::Document)

Print doc with formatting.

Constructors

EzXML.HTMLDocumentFunction
HTMLDocument(uri=nothing, externalID=nothing)

Create an HTML document.

EzXML.HTMLDocumentNodeFunction
HTMLDocumentNode(uri, externalID)

Create an HTML document node.

uri and externalID are either a string or nothing.

EzXML.TextNodeFunction
TextNode(content)

Create a text node with content.

EzXML.CommentNodeFunction
CommentNode(content)

Create a comment node with content.

EzXML.CDataNodeFunction
CDataNode(content)

Create a CDATA node with content.

EzXML.AttributeNodeFunction
AttributeNode(name, value)

Create an attribute node with name and value.

EzXML.DTDNodeFunction
DTDNode(name, [systemID, [externalID]])

Create a DTD node with name, systemID, and externalID.

Node types

Node typeInteger
EzXML.ELEMENT_NODE1
EzXML.ATTRIBUTE_NODE2
EzXML.TEXT_NODE3
EzXML.CDATA_SECTION_NODE4
EzXML.ENTITY_REF_NODE5
EzXML.ENTITY_NODE6
EzXML.PI_NODE7
EzXML.COMMENT_NODE8
EzXML.DOCUMENT_NODE9
EzXML.DOCUMENT_TYPE_NODE10
EzXML.DOCUMENT_FRAG_NODE11
EzXML.NOTATION_NODE12
EzXML.HTML_DOCUMENT_NODE13
EzXML.DTD_NODE14
EzXML.ELEMENT_DECL15
EzXML.ATTRIBUTE_DECL16
EzXML.ENTITY_DECL17
EzXML.NAMESPACE_DECL18
EzXML.XINCLUDE_START19
EzXML.XINCLUDE_END20
EzXML.DOCB_DOCUMENT_NODE21

Node accessors

EzXML.nodetypeMethod
nodetype(node::Node)

Return the type of node as an integer.

EzXML.nodenameMethod
nodename(node::Node)

Return the node name of node.

EzXML.namespaceMethod
namespace(node::Node)

Return the namespace associated with node.

EzXML.namespacesMethod
namespaces(node::Node)

Create a vector of namespaces applying to node.

EzXML.hasnamespaceMethod
hasnamespace(node::Node)

Return if node is associated with a namespace.

EzXML.iselementMethod
iselement(node::Node)

Return if node is an element node.

EzXML.isattributeMethod
isattribute(node::Node)

Return if node is an attribute node.

EzXML.istextMethod
istext(node::Node)

Return if node is a text node.

EzXML.iscdataMethod
iscdata(node::Node)

Return if node is a CDATA node.

EzXML.iscommentMethod
iscomment(node::Node)

Return if node is a comment node.

EzXML.isdtdMethod
isdtd(node::Node)

Return if node is a DTD node.

EzXML.countnodesMethod
countnodes(parent::Node)

Count the number of child nodes of parent.

EzXML.countelementsMethod
countelements(parent::Node)

Count the number of child elements of parent.

EzXML.systemIDMethod
systemID(node::Node)

Return the system ID of node.

EzXML.externalIDMethod
externalID(node::Node)

Return the external ID of node.

Node modifiers

EzXML.setnodename!Method
setnodename!(node::Node, name::AbstractString)

Set the name of node.

EzXML.setnodecontent!Method
setnodecontent!(node::Node, content::AbstractString)

Replace the content of node.

Document properties

EzXML.versionFunction
version(doc::Document)

Return the version string of doc.

EzXML.encodingFunction
encoding(doc::Document)

Return the encoding string of doc.

EzXML.hasversionFunction
hasversion(doc::Document)

Return if doc has a version string.

EzXML.hasencodingFunction
hasencoding(doc::Document)

Return if doc has an encoding string.

DOM tree accessors

EzXML.documentFunction
document(node::Node)

Return the document of node.

EzXML.rootFunction
root(doc::Document)

Return the root element of doc.

EzXML.dtdFunction
dtd(doc::Document)

Return the DTD node of doc.

EzXML.firstnodeFunction
firstnode(node::Node)

Return the first child node of node.

EzXML.lastnodeFunction
lastnode(node::Node)

Return the last child node of node.

EzXML.firstelementFunction
firstelement(node::Node)

Return the first child element of node.

EzXML.lastelementFunction
lastelement(node::Node)

Return the last child element of node.

EzXML.nextnodeFunction
nextnode(node::Node)

Return the next node of node.

EzXML.prevnodeFunction
prevnode(node::Node)

Return the previous node of node.

EzXML.nextelementFunction
nextelement(node::Node)

Return the next element of node.

EzXML.prevelementFunction
prevelement(node::Node)

Return the previous element of node.

EzXML.eachnodeFunction
eachnode(node::Node, [backward=false])

Create an iterator of child nodes.

EzXML.nodesFunction
nodes(node::Node, [backward=false])

Create a vector of child nodes.

EzXML.eachelementFunction
eachelement(node::Node, [backward=false])

Create an iterator of child elements.

EzXML.elementsFunction
elements(node::Node, [backward=false])

Create a vector of child elements.

EzXML.eachattributeFunction
eachattribute(node::Node)

Create an iterator of attributes.

eachattribute(reader::StreamReader)

Return an AttributeReader object for the current node of reader

EzXML.attributesFunction
attributes(node::Node)

Create a vector of attributes.

EzXML.hasrootFunction
hasroot(doc::Document)

Return if doc has a root element.

EzXML.hasdtdFunction
hasdtd(doc::Document)

Return if doc has a DTD node.

EzXML.hasnodeFunction
hasnode(node::Node)

Return if node has a child node.

EzXML.hasprevnodeFunction
hasprevnode(node::Node)

Return if node has a previous node.

EzXML.haselementFunction
haselement(node::Node)

Return if node has a child element.

EzXML.hasdocumentFunction
hasdocument(node::Node)

Return if node belongs to a document.

DOM tree modifiers

EzXML.setroot!Function
setroot!(doc::Document, node::Node)

Set the root element of doc to node and return the root element.

EzXML.setdtd!Function
setdtd!(doc::Document, node::Node)

Set the DTD node of doc to node and return the DTD node.

EzXML.link!Function
link!(parent::Node, child::Node)

Link child at the end of children of parent.

EzXML.linknext!Function
linknext!(target::Node, node::Node)

Link node as the next sibling of target.

EzXML.linkprev!Function
linkprev!(target::Node, node::Node)

Link node as the prev sibling of target.

EzXML.unlink!Function
unlink!(node::Node)

Unlink node from its context.

EzXML.addelement!Function
addelement!(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.findallMethod
findall(xpath::AbstractString, doc::Document)

Find nodes matching xpath XPath query from doc.

Base.findfirstMethod
findfirst(xpath::AbstractString, doc::Document)

Find the first node matching xpath XPath query from doc.

Base.findlastMethod
findlast(doc::Document, xpath::AbstractString)

Find the last node matching xpath XPath query from doc.

Base.findallMethod
findall(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.findfirstMethod
findfirst(xpath::AbstractString, node::Node, [ns=namespaces(node)])

Find the first node matching xpath XPath query starting from node.

Base.findlastMethod
findlast(node::Node, xpath::AbstractString, [ns=namespaces(node)])

Find the last node matching xpath XPath query starting from node.

Validation

EzXML.validateFunction
validate(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.readdtdFunction
readdtd(filename::AbstractString)

Read filename and create a DTD node.

Reader node types

Node typeInteger
EzXML.READER_NONE0
EzXML.READER_ELEMENT1
EzXML.READER_ATTRIBUTE2
EzXML.READER_TEXT3
EzXML.READER_CDATA4
EzXML.READER_ENTITY_REFERENCE5
EzXML.READER_ENTITY6
EzXML.READER_PROCESSING_INSTRUCTION7
EzXML.READER_COMMENT8
EzXML.READER_DOCUMENT9
EzXML.READER_DOCUMENT_TYPE10
EzXML.READER_DOCUMENT_FRAGMENT11
EzXML.READER_NOTATION12
EzXML.READER_WHITESPACE13
EzXML.READER_SIGNIFICANT_WHITESPACE14
EzXML.READER_END_ELEMENT15
EzXML.READER_END_ENTITY16
EzXML.READER_XML_DECLARATION17

Streaming reader

EzXML.expandtreeMethod
expandtree(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.nodetypeMethod
nodetype(reader::StreamReader)

Return the type of the current node of reader.

EzXML.nodenameMethod
nodename(reader::StreamReader)

Return the name of the current node of reader.

EzXML.nodecontentMethod
nodecontent(reader::StreamReader)

Return the content of the current node of reader.

EzXML.nodedepthMethod
nodedepth(reader::StreamReader)

Return the depth of the current node of reader.

EzXML.namespaceMethod
namespace(reader::StreamReader)

Return the namespace of the current node of reader.

EzXML.hasnodecontentMethod
hasnodecontent(reader::StreamReader)

Return if the current node of reader has content.

EzXML.hasnodenameMethod
hasnodename(reader::StreamReader)

Return if the current node of reader has a node name.