private Collection parseTreeCollection ( Element collectionElement ) { Collection collection = new Collection ( ) ; parseCommonFields ( collectionElement , collection ) ; collection . setTitle ( collectionElement . getAttribute ( "title" ) ) ; collection . setDescription ( collectionElement . getAttribute ( "description" ) ) ; // Collections can contain either sets or collections (but not both) NodeList childCollectionElements = collectionElement . getElementsByTagName ( "collection" ) ; for ( int i = 0 ; i < childCollectionElements . getLength ( ) ; i ++ ) { Element childCollectionElement = ( Element ) childCollectionElements . item ( i ) ; collection . addCollection ( parseTreeCollection ( childCollectionElement ) ) ; } NodeList childPhotosetElements = collectionElement . getElementsByTagName ( "set" ) ; for ( int i = 0 ; i < childPhotosetElements . getLength ( ) ; i ++ ) { Element childPhotosetElement = ( Element ) childPhotosetElements . item ( i ) ; collection . addPhotoset ( createPhotoset ( childPhotosetElement ) ) ; } return collection ; }
Parse the XML for a collection as returned by getTree call .