The XML file countries.xml has the following data
and structure:
< countries >
< country id=???italy???
country=???Italy???
lang=???it???
currency=???euro??? / >
< country id=???canada???
country=???Canada???
lang=???en,fr???
currency=???canadian dollar??? / >
< country id=???usa???
country=???United States of America???
lang=???en???
currency=???dollar??? / >
< /countries >
In the haXe code, the referenced file is used two times, once to set the compiler constraint in the XML
Proxy and the other to load the file as a resource; don ??™ t forget to add the - resource countries.xml@
countries switch in your compiler command.
Part III: Extending the Possibilities
464
class LocaleProxy extends haxe.xml.Proxy < ???countries.xml???, Locale > { }
class Main
{
public static function main()
{
var locales = getLocales();
trace(locales.italy.country);
//trace(locales.uusa.country); // does not compile because misspelled
}
public static function getLocales()
{
var doc = Xml.parse(Std.resource(???countries???));
var h = new Hash();
for(n in doc.
Pages:
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862