All pastes #921699 Raw Edit

Unnamed

public text v1 · immutable
#921699 ·published 2008-02-28 07:10 UTC
rendered paste body
String parentName = root.getTagName();

// Verify that any Required tags are present
if( required ) {
	NodeList nl = root.getElementsByTagName( tagName );
	if( nl.getLength() < 1 )
		throw new MissingRequiredTag( tagName, parentName );
}

// Proccess all child tags
nl = root.getChildNodes();
for(int i=0; i<nl.getLength(); i++) {
	Node n = nl.item(i);
	if( n.getNodeType() == Node.ELEMENT_NODE ) {
		Element e = (Element)n;

		if( e.getTagName().equals( tagName ) ) {
			callbackFunc(e);
		}else{
			String childTag = e.getTagName();
			throw new UnknownXMLTag( tagName, childTag );
		}
	}
}// End for i