haXe XPath Documentation
Back | Index
class dcxml.Xml
Class representing an XML node.
var firstChild(default,null) : Xml
reference to first and last child nodes
var lastChild(default,null) : Xml
var name(default,null) : String
name of the node (only set for element and attribute nodes)
var nextSibling(default,null) : Xml
var parent(default,null) : Xml
reference to parent node, or null if this node has no parent
var previousSibling(default,null) : Xml
reference to previous and next sibling nodes in document order, or null if there are no previous or next sibling nodes
var text(default,null) : String
text of the node (only set for text, attribute, processing instruction and doctype nodes)
var type(default,null) : XmlType
type of the node
function addChild(child : Xml) : Void
Inserts a child node after existing children. Throws XmlException if the child already has a parent.
function attributes() : Iterator<Xml>
Gets an iterator over all attributes.
function elements() : Iterator<Xml>
Gets an iterator over child elements in document order.
function elementsNamed(name : String) : Iterator<Xml>
Gets an iterator over all child elements with the specified name in document order.
function existsAttribute(name : String) : Bool
Tests if an attribute with the specified name exists.
function getAttribute(name : String) : Xml
Gets an attribute.
function getAttributeValue(name : String) : String
Gets the value of an attribute.
function getChild(?i : Int) : Xml
Gets the child with the specified index.
function getNode(?i : Int) : Xml
Gets the node that is i steps away in document order; or, if i is negative, the node that is -i steps away in reverse document order.
function getSibling(i : Int) : Xml
Gets the sibling that is i steps away in document order; or, if i is negative, the sibling that is -i steps away in reverse document order.
function getStringValue() : String
Gets the string value of the node per XPath spec:
  • For document and element nodes, the concatenation of the string values of all text node descendants in document order.
  • For processing instruction nodes, the part of the processing instruction following any target and any whitespace, not including the terminating ?>.
  • For text nodes, the character data.
function insertChild(?i : Int, child : Xml) : Void
Inserts a child node at the specified index. Throws XmlException if the specified index is out of bounds. Throws XmlException if the child node already has a parent.
function insertSiblingAfter(sibling : Xml) : Void
Inserts a sibling after this node.
function insertSiblingBefore(sibling : Xml) : Void
Inserts a sibling before this node.
function iterator() : Iterator<Xml>
Gets an iterator over children in document order.
function remove() : Void
Removes the node from the XML document.
function removeAttribute(name : String) : Void
Removes an attribute.
function setAttributeValue(name : String, value : String) : Void
Sets an attribute value.
function toString() : String
Gets the string markup representation of the XML node.
static function createDocument() : Xml
Creates an XML document node.
static function createElement(name : String, ?attributes : Hash<String>) : Xml
Creates an XML element node.
static function createProcessingInstruction(name : String, text : String) : Xml
Creates an XML processing instruction node.
static function createText(text : String) : Xml
Creates an XML text node.
static function parse(xmlString : String) : Xml
Parses XML input from a string.
static function parseFromHTTP(url : String) : Xml
Downloads an XML document via HTTP and parses it.
Back | Index