The haxe.xml.Access API helps providing a fast dot-syntax access to the most common Xml methods.

Static variables

staticread onlyx:Xml

staticread onlyname:String

The name of the current element. This is the same as Xml.nodeName.

staticread onlyinnerData:String

The inner PCDATA or CDATA of the node.

An exception is thrown if there is no data or if there not only data but also other nodes.

staticread onlyinnerHTML:String

The XML string built with all the sub nodes, excluding the current one.

staticread onlynode:NodeAccess

Access to the first sub element with the given name.

An exception is thrown if the element doesn't exists. Use hasNode to check the existence of a node.

var access = new haxe.xml.Access(Xml.parse("<user><name>John</name></user>"));
var user = access.node.user;
var name = user.node.name;
trace(name.innerData); // John

// Uncaught Error: Document is missing element password
var password = user.node.password;

staticread onlynodes:NodeListAccess

Access to the List of elements with the given name.

var fast = new haxe.xml.Access(Xml.parse("
	<users>
		<user name='John'/>
		<user name='Andy'/>
		<user name='Dan'/>
	</users>"
));

var users = fast.node.users;
for (user in users.nodes.user) {
	trace(user.att.name);
}

staticread onlyatt:AttribAccess

Access to a given attribute.

An exception is thrown if the attribute doesn't exists. Use has to check the existence of an attribute.

var f = new haxe.xml.Access(Xml.parse("<user name='Mark'></user>"));
var user = f.node.user;
if (user.has.name) {
	trace(user.att.name); // Mark
}

staticread onlyhas:HasAttribAccess

Check the existence of an attribute with the given name.

staticread onlyhasNode:HasNodeAccess

Check the existence of a sub node with the given name.

var f = new haxe.xml.Access(Xml.parse("<user><age>31</age></user>"));
var user = f.node.user;
if (user.hasNode.age) {
	trace(user.node.age.innerData); // 31
}

staticread onlyelements:Iterator<Access>

The list of all sub-elements which are the nodes with type Xml.Element.

Static methods

staticinlineget_x(this:Xml):Xml