outputNode( node, indent )
{
// e.g., in the case of a <td> tag the getName call
// will return the text "td".
if( node.getName()!=null )
{
openTag = new StringBuffer();
openTag.append( indent + " <" + node.getName() );
// The getAttributes method returns an ArrayList of
// KeyValue objects.
for( iter = node.getAttributes().iterator(); iter.hasNext(); )
{
attribute = iter.next();
openTag.append( " " + attribute.getKey() + "=\"" + attribute.getValue() + "\"" );
}
openTag.append( ">" );
session.log( openTag.toString() );
}
// e.g., in the case of <td>foo</td> the getValue method
// call will return the text "foo".
if( node.getValue()!=null )
{
session.log( indent + " " + node.getValue() );
}
// getChildNodes returns an ArrayList of XmlNode objects.
for( iter = node.getChildNodes().iterator(); iter.hasNext(); )
{
childNode = iter.next();
outputNode( childNode, indent + "--" );
}
if( node.getName()!=null )
{
session.log( indent + " </" + node.getName() + ">" );
}
}
// Match all <td> tags.
node = scrapeableFile.applyXPathExpression( "//td" );
// Note that there is an equivalent sutil
// method call: sutil.applyXPathExpression( String content, String expression )
// If the content parameter doesn't contain a well-formed
// block of XML an exception will be thrown.
outputNode( node, "" );