public Document makeStationCollectionDocument() throws IOException {
    Element rootElem = new Element("stationCollection");
    Document doc = new Document(rootElem);

    List stns = sobs.getStations();
    System.out.println("nstns = "+stns.size());
    for (int i = 0; i < stns.size(); i++) {
      ucar.unidata.geoloc.Station s = (ucar.unidata.geoloc.Station) stns.get(i);
      Element sElem = new Element("station");
      sElem.setAttribute("name",s.getName());
      if (s.getWmoId() != null)
        sElem.setAttribute("wmo_id",s.getWmoId());
      if (s.getDescription() != null)
        sElem.addContent(new Element("description").addContent(s.getDescription()));

      sElem.addContent(new Element("longitude").addContent( ucar.unidata.util.Format.d(s.getLongitude(), 6)));
      sElem.addContent(new Element("latitide").addContent( ucar.unidata.util.Format.d(s.getLatitude(), 6)));
      if (!Double.isNaN(s.getAltitude()))
        sElem.addContent(new Element("altitude").addContent( ucar.unidata.util.Format.d(s.getAltitude(), 6)));
      rootElem.addContent(sElem);
    }

    return doc;
  }
public Document makeStationCollectionDocument() throws IOException {
    Element rootElem = new Element("stationCollection");
    Document doc = new Document(rootElem);

    List stns = sobs.getStations();
    System.out.println("nstns = "+stns.size());
    for (int i = 0; i < stns.size(); i++) {
      ucar.unidata.geoloc.Station s = (ucar.unidata.geoloc.Station) stns.get(i);
      Element sElem = new Element("station");
      sElem.setAttribute("name",s.getName());
      if (s.getWmoId() != null)
        sElem.setAttribute("wmo_id",s.getWmoId());
      if (s.getDescription() != null)
        sElem.addContent(new Element("description").addContent(s.getDescription()));

      sElem.addContent(new Element("longitude").addContent( ucar.unidata.util.Format.d(s.getLongitude(), 6)));
      sElem.addContent(new Element("latitide").addContent( ucar.unidata.util.Format.d(s.getLatitude(), 6)));
      if (!Double.isNaN(s.getAltitude()))
        sElem.addContent(new Element("altitude").addContent( ucar.unidata.util.Format.d(s.getAltitude(), 6)));
      rootElem.addContent(sElem);
    }

    return doc;
  }
public Document makeStationCollectionDocument ( ) throws IOException { Element rootElem = new Element ( "stationCollection" ) ; Document doc = new Document ( rootElem ) ; List stns = sobs . getStations ( ) ; System . out . println ( "nstns = " + stns . size ( ) ) ; for ( int i = 0 ; i < stns . size ( ) ; i ++ ) { ucar . unidata . geoloc . Station s = ( ucar . unidata . geoloc . Station ) stns . get ( i ) ; Element sElem = new Element ( "station" ) ; sElem . setAttribute ( "name" , s . getName ( ) ) ; if ( s . getWmoId ( ) != null ) sElem . setAttribute ( "wmo_id" , s . getWmoId ( ) ) ; if ( s . getDescription ( ) != null ) sElem . addContent ( new Element ( "description" ) . addContent ( s . getDescription ( ) ) ) ; sElem . addContent ( new Element ( "longitude" ) . addContent ( ucar . unidata . util . Format . d ( s . getLongitude ( ) , 6 ) ) ) ; sElem . addContent ( new Element ( "latitide" ) . addContent ( ucar . unidata . util . Format . d ( s . getLatitude ( ) , 6 ) ) ) ; if ( ! Double . isNaN ( s . getAltitude ( ) ) ) sElem . addContent ( new Element ( "altitude" ) . addContent ( ucar . unidata . util . Format . d ( s . getAltitude ( ) , 6 ) ) ) ; rootElem . addContent ( sElem ) ; } return doc ; }
Create an XML document from this info
Create an XML document from this info