28 lines
1.0 KiB
Plaintext
28 lines
1.0 KiB
Plaintext
use XML;
|
|
|
|
bundle Default {
|
|
class Test {
|
|
function : Main(args : String[]) ~ Nil {
|
|
in := String->New();
|
|
in->Append("<Students>");
|
|
in->Append("<Student Name=\"April\" Gender=\"F\" DateOfBirth=\"1989-01-02\" />");
|
|
in->Append("<Student Name=\"Bob\" Gender=\"M\" DateOfBirth=\"1990-03-04\" />");
|
|
in->Append("<Student Name=\"Chad\" Gender=\"M\" DateOfBirth=\"1991-05-06\" />");
|
|
in->Append("<Student Name=\"Dave\" Gender=\"M\" DateOfBirth=\"1992-07-08\">");
|
|
in->Append("<Pet Type=\"dog\" Name=\"Rover\" />");
|
|
in->Append("</Student>");
|
|
in->Append("<Student DateOfBirth=\"1993-09-10\" Gender=\"F\" Name=\"Émily\" /></Students>");
|
|
|
|
parser := XmlParser->New(in);
|
|
if(parser->Parse()) {
|
|
root := parser->GetRoot();
|
|
children := root->GetChildren("Student");
|
|
each(i : children) {
|
|
child : XMLElement := children->Get(i)->As(XMLElement);
|
|
XMLElement->DecodeString(child->GetAttribute("Name"))->PrintLine();
|
|
};
|
|
};
|
|
}
|
|
}
|
|
}
|