XML tree parsing is declared using the xmltree profile, and initiated with parseXml (in this case reading from ‶standard input″):
program xmltree, textpatterns;
parseXml ();
choose xmlElementNode ("doc") {
println (".startdoc"); processChildren; println (".enddoc");
}
choose xmlElementNode ("p") :> processChildren;
choose xmlElementNode ("list") {
println (".startlist"); processChildren; println (".endlist");
}
choose xmlElementNode ("item") {
print (".item "); processChildren;
}
choose xmlTextNode =
println (*.data) unless *.data matches ([" \t\n"]* & -|);
| Beyond OmniMark | Sam Wilmott |
| Slide 18 of 37 | www.wilmott.ca |