use XML; bundle Default { class Test { function : Main(args : String[]) ~ Nil { in := String->New(); in->Append(""); in->Append("
"); in->Append(""); in->Append("Invisibility Cream"); in->Append("14.50"); in->Append("Makes you invisible"); in->Append(""); in->Append(""); in->Append("Levitation Salve"); in->Append("23.99"); in->Append("Levitate yourself for up to 3 hours per application"); in->Append(""); in->Append("
"); in->Append("
"); in->Append(""); in->Append("Blork and Freen Instameal"); in->Append("4.95"); in->Append("A tasty meal in a tablet; just add water"); in->Append(""); in->Append(""); in->Append("Grob winglets"); in->Append("3.56"); in->Append("Tender winglets of Grob. Just add water"); in->Append(""); in->Append("
"); in->Append("
"); parser := XmlParser->New(in); if(parser->Parse()) { # get first item results := parser->FindElements("//inventory/section[1]/item[1]"); if(results <> Nil) { IO.Console->Instance()->Print("items: ")->PrintLine(results->Size()); }; # get all prices results := parser->FindElements("//inventory/section/item/price"); if(results <> Nil) { each(i : results) { element := results->Get(i)->As(XMLElement); element->GetContent()->PrintLine(); }; }; # get names results := parser->FindElements("//inventory/section/item/name"); if(results <> Nil) { IO.Console->Instance()->Print("names: ")->PrintLine(results->Size()); }; }; } } }