%%% XML reading tests

:- eval(test_xml1()).

test_xml1() :-
	% This extends the standard DOM API: create a Document based on File name
	Document=XML("blast.xml"),
	Root = Document.getDocumentElement(),
%	RootAttributes = Root.getAttributes(),
	Elements = Root.getElementsByTagName("Hit"),
	% This extends the standard DOM API: enumerate the nodes
	Elements.nodes(Element),
	SubElements = Element.getElementsByTagName("Hsp"),
	SubElements.nodes(SubElement),
	SubElementNodeName = SubElement.getNodeName(),
println(["SubElement name: ",SubElementNodeName]),
%	Attributes = Element.getAttributes(),
%	% This extends the standard DOM API: enumerate the attributes
%	Attributes.nodes(Attribute),
%	AttributeName=Attribute.getName(),
%	AttributeValue=Attribute.getValue(),
%println(["Attribute:",AttributeName,AttributeValue]," "),
	ChildNodes=SubElement.getChildNodes(),
	ChildNodes.nodes(ChildNode),
	ChildNodeName = ChildNode.getNodeName(),
	DataName = ChildNode.getFirstChild(),
	StringName = DataName.getNodeValue(),
println(["   Child name: ",ChildNodeName]),
println(["   Child value: ",StringName]).
