Prev | Current Page 835 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Each variable performs a different kind of filtering action on the node. If the filter needs an
??‘
??‘
??‘
??‘
??‘
Part III: Extending the Possibilities
456
argument to be applied, this is passed as an instance variable to the operator. Take a look at the following
example:
var doc = Xml.parse(??? < person name=???John???/ > ??™);
var n = new haxe.xml.Fast(doc);
trace(n.node.person.att.name);
The n variable is an Xml node wrapped in a Fast object; the node variable states that the first element
whose name is equal to person must be returned. The type of person is Fast to permit further filtering
and traversing; thus it is possible to access the attribute name using att.name .
The Xml class returns a null value when an inexistent node or attribute is retrieved while the Fast class
throws an exception when this happens. This runtime check ensures that names are used correctly to
query the XML document.
Traversing Elements
An XML node can be traversed using the following operators: elements , nodes , and node .


Pages:
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847