title: Problems with JAXB XML parsing
body: <p>I’m working on a project in which I will use JAXB to parse an XML file containing the following weather station information: Name, station ID, latitude/longitude, and url. Right now I intend to test everything by printing a weather station by name only. I have debugged my code but when I try to run: I get the following error:</p>
  
  <p>Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"wx_station_index"). Expected elements are (none)</p>
  
  <p>Does anyone have an explanation? Any help would be appreciated. My code and sample of XML are posted below:</p>
  
  <pre><code>//create criteria for weather station info
  @XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  public class StationTest {
  
  /**
   * @param args
   */
  
  @XmlElement(name = "station_id")
  String station_id;
  
  @XmlElement(name = "state")
  String state;
  
  @XmlElement(name = "station_name")
  String stationName;
  
  @XmlElement(name = "latitude")
  double latitude;
  
  @XmlElement(name = "longitude")
  double longitude;
  
  @XmlElement(name = "html_url")
  String htmlUrl;
  
  public String getStationID(){
      return station_id;
  }
  
  public void setStationId(String station_id)
  {
       this.station_id = station_id;
  }
  
  public String getState(){
      return state;
  }
  
  public void setState(String state)
  {
       this.state = state;
  }
  
  public String getStationName(){
      return stationName;
  }
  
  public void setStationName(String station_name)
  {
       this.stationName = stationName;
  }
  
  public double getLatitude(){
      return latitude;
  }
  
  public void setLatitude(double latitude)
  {
       this.latitude = latitude;
  }
  
  public double getLongitude(){
      return longitude;
  }
  
  public void setLongitude(double longitude)
  {
       this.longitude = longitude;
  }
  
  public String getUrl(){
      return htmlUrl;
  }
  
  public void setUrl(String url){
      this.htmlUrl = htmlUrl;
  
  }
  </code></pre>
  
  <p>}
      import java.util.ArrayList;</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlSeeAlso;
  import javax.xml.bind.annotation.XmlAccessType;
  
  //create list for all weather stations
  
  @XmlRootElement
  @XmlSeeAlso(value = StationTest.class)
  @XmlAccessorType(XmlAccessType.FIELD)
  public class StationListTest {
  
  /**
   * @param args
   */
  @XmlElement(name = "station")
  private ArrayList&lt;StationTest&gt; stationList;
  
  public void setStationListTest(ArrayList&lt;StationTest&gt; StationList){
      this.stationList = StationList;
  }
  
  public ArrayList&lt;StationTest&gt; getStationListTest(){
      return stationList;
  }
  
  }
  
  import java.util.ArrayList;
  
  import javax.xml.bind.JAXBContext;
  import javax.xml.bind.JAXBException;
  import javax.xml.bind.Unmarshaller;
  
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.util.ArrayList;
  
   import javax.xml.bind.JAXBContext;
  import javax.xml.bind.JAXBException;
  import javax.xml.bind.Unmarshaller;
  
  //final Test of JAXB
  public class Test3 {
  
  /**
   * @param args
   */
  //read xml
  private static final String STATION_XML = "src/flwxindex3.xml";
  
  //main method
  public static void main(String[] args) throws InterruptedException, JAXBException, FileNotFoundException {
  
      //create list object
      ArrayList&lt;StationTest&gt; StationList = new ArrayList&lt;StationTest&gt;();
  
      final JAXBContext jaxbc = JAXBContext.newInstance(StationListTest.class);
      final Unmarshaller unmarshaller = jaxbc.createUnmarshaller();
  
      //create list for iteration, then iterate printing by name only
      StationListTest stationListTest = (StationListTest) unmarshaller.unmarshal(new FileReader(STATION_XML));
      ArrayList&lt;StationTest&gt; list = stationListTest.getStationListTest();
      //final StationListTest stations = (StationListTest) unmarshaller.unmarshal(Thread.currentThread().getContextClassLoader().getResource("src/flwxindex3.xml"));
      for (final StationTest station : list) {
          System.out.println(station.getStationName());
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The actual xml as requested (Thought I included it, sorry):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;wx_station_index&gt;
      &lt;credit&gt;NOAA's National Weather Service&lt;/credit&gt;
      &lt;credit_URL&gt;http://weather.gov/&lt;/credit_URL&gt;
      &lt;image&gt;
              &lt;url&gt;http://weather.gov/images/xml_logo.gif&lt;/url&gt;
              &lt;title&gt;NOAA's National Weather Service&lt;/title&gt;
              &lt;link&gt;http://weather.gov&lt;/link&gt;
      &lt;/image&gt;
      &lt;suggested_pickup&gt;08:00 EST&lt;/suggested_pickup&gt;
      &lt;suggested_pickup_period&gt;1140&lt;/suggested_pickup_period&gt;
  
  &lt;station&gt;
      &lt;station_id&gt;NFNA&lt;/station_id&gt;
      &lt;state&gt;FJ&lt;/state&gt;
      &lt;station_name&gt;Nausori&lt;/station_name&gt;
      &lt;latitude&gt;-18.05&lt;/latitude&gt;
      &lt;longitude&gt;178.567&lt;/longitude&gt;
      &lt;html_url&gt;http://weather.noaa.gov/weather/current/NFNA.html&lt;/html_url&gt;
      &lt;rss_url&gt;http://weather.gov/xml/current_obs/NFNA.rss&lt;/rss_url&gt;
      &lt;xml_url&gt;http://weather.gov/xml/current_obs/NFNA.xml&lt;/xml_url&gt;
  &lt;/station&gt;
  
  &lt;station&gt;
      &lt;station_id&gt;KCEW&lt;/station_id&gt;
      &lt;state&gt;FL&lt;/state&gt;
              &lt;station_name&gt;Crestview, Sikes Airport&lt;/station_name&gt;
      &lt;latitude&gt;30.79&lt;/latitude&gt;
      &lt;longitude&gt;-86.52&lt;/longitude&gt;
              &lt;html_url&gt;http://weather.noaa.gov/weather/current/KCEW.html&lt;/html_url&gt;
              &lt;rss_url&gt;http://weather.gov/xml/current_obs/KCEW.rss&lt;/rss_url&gt;
              &lt;xml_url&gt;http://weather.gov/xml/current_obs/KCEW.xml&lt;/xml_url&gt;
  &lt;/station&gt;
  </code></pre>