I'm currently writing a basic weather app for university which includes retrieving the weather info from the BBC weather RSS feed.

I have it all set up to output the RSS feed into a file (output.xml), which the parser class will then use to build the tree.

However I am getting `The markup in the document following the root element must be well- formed.`
error when I run it.

Upon inspecting the downloaded XML file I noticed that the first two nodes are missing.

Here is the downloaded XML:

```
<channel>
    <atom:link href="http://open.live.bbc.co.uk/weather/feeds/en/2656397/observations.rss" rel="self" type="application/rss+xml" />
    <title>BBC Weather - Observations for  Bangor, United Kingdom</title>
    <link>http://www.bbc.co.uk/weather/2656397</link>
    <description>Latest observations for Bangor from BBC Weather, including weather, temperature and wind information</description>
    <language>en</language>
    <copyright>Copyright: (C) British Broadcasting Corporation, see http://www.bbc.co.uk/terms/additional_rss.shtml for more details</copyright>
    <pubDate>Thu, 12 Mar 2015 05:35:08 +0000</pubDate>
    <item>
      <title>Thursday - 05:00 GMT: Thick Cloud, 10°C (50°F)</title>
      <link>http://www.bbc.co.uk/weather/2656397</link>
      <description>Temperature: 10°C (50°F), Wind Direction: South Easterly, Wind Speed: 8mph, Humidity: 90%, Pressure: 1021mb, Falling, Visibility: Very Good</description>
      <pubDate>Thu, 12 Mar 2015 05:35:08 +0000</pubDate>
      <guid isPermaLink="false">http://www.bbc.co.uk/weather/2656397-2015-03-12T05:35:08.000Z</guid>
      <georss:point>53.22647 -4.13459</georss:point>
    </item>
  </channel>
</rss>

```

The XML should have the following two nodes before the `<channel>` node:

```
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" version="2.0">

```

Here is the code I use to retrieve the XML file:

```
public static void main(String[] args) throws SAXException, IOException, XPathExpressionException {
    URL url = new URL("http://open.live.bbc.co.uk/weather/feeds/en/2656397/observations.rss");
    URLConnection con = url.openConnection();
    StringBuilder builder;
    try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {

        builder = new StringBuilder();
        String line;

        if (!in.readLine().isEmpty()) {
            line = in.readLine();
        }

        while ((line = in.readLine()) != null) {
            builder.append(line).append("\n");
        }

        String input = builder.toString();

        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("output.xml"))));
        out.write(input);
        out.flush();
    }
    try {
        WeatherParser parser = new WeatherParser();
        System.out.println(parser.parse("output.xml"));
    } catch (ParserConfigurationException ex) {
    }
}

```

And here is the code for parsing the XML (`WeatherParser.java`):

```
public class WeatherParser {

    public WeatherParser() throws ParserConfigurationException {
        xpfactory = XPathFactory.newInstance();
        path = xpfactory.newXPath();
        dbfactory = DocumentBuilderFactory.newInstance();
        builder = dbfactory.newDocumentBuilder();
    }

    public String parse(String fileName) throws SAXException, IOException, XPathExpressionException {
        File f = new File(fileName);
        org.w3c.dom.Document doc = builder.parse(f);
        StringBuilder info = new StringBuilder();
        info.append(path.evaluate("/channel/item/title", doc));
        return info.toString();
    }

    private DocumentBuilderFactory dbfactory;
    private DocumentBuilder builder;
    private XPathFactory xpfactory;
    private XPath path;
}

```

Hope this was enough information provided.