import java.io.*;
import dk.brics.xact.*;
public class PhoneList {
@Namespace public static final String c = "http://businesscard.org";
@Namespace public static final String h = "http://www.w3.org/1999/xhtml";
public static void main(String[] args)
throws XactException, IOException {
XML wrapper = [[
<[TITLE]>
<[TITLE]>
<[MAIN]>
]];
XML cardlist = XML.get("file:cards.xml", "c:cardlist");
XML x = wrapper.plug("TITLE", "My Phone List")
.plug("MAIN", [[<[CARDS]>]]);
for (XML card : cardlist.select("c:card[c:phone]"))
x = x.plug("CARDS", [[
<{ card.select("c:name/text()") }>,
phone: <{ card.select("c:phone/text()") }>
<[CARDS]>]]);
System.out.println(x.close());
}
}