Prev | Current Page 836 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The first
returns all the elements that are children of the current node. The nodes operator does the same but
filters the nodes by name, and node returns only the first node of the list.
Suppose you have an XML document with the following content:
< ?xml version=???1.0??? ? >
< people >
< person >
< name > John Doe < /name >
< bio >
Biography goes here ...
< /bio >
< /person >
< author >
< name > William Shakespeare < /name >
< bio >
Very long biography here ...
< /bio >
< /author >
< person sex=???f??? >
< name > Jane Doe < /name >
< bio / > < !-- she has not a biography -- >
< /person >
< person sex=???m??? >
< name > Richard Roe < /name >
< bio > The antagonist. < /bio >
< /person >
< /people >
The following example illustrates the effect and use of the three operators supposing that the document
is stored in a resource file referenced as sample .
class Main
{
public static function main()
Chapter 16: haXe Advanced Topics
457
{
var doc = Xml.parse(Std.resource(???sample???));
var fdoc = new haxe.


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