import java.io.*; import java.util.*; import org.geotools.feature.Feature; import org.geotools.feature.FeatureCollection; import com.vividsolutions.jts.geom.Point; import org.geotools.feature.simple.SimpleFeatureImpl; import org.geotools.gml3.ApplicationSchemaConfiguration; import org.geotools.gml3.GMLConfiguration; public class TestGeoTools2 { public static void main(String[] argv) throws Exception{ GMLConfiguration configuration = new GMLConfiguration(); org.geotools.xml.Parser parser = new org.geotools.xml.Parser(configuration); // Part 1: the gml instance document InputStream xml = new FileInputStream("sensorML.xml"); // Part 2: parse the gml FeatureCollection fc = (FeatureCollection) parser.parse( xml ); // Part 3: iterate through the collection, to get each feature for ( Iterator i = fc.iterator(); i.hasNext(); ) { SimpleFeatureImpl f = (SimpleFeatureImpl)i.next(); String name = (String) f.getAttribute( "NAME" ); System.out.println(name); } } }