title: Error trying to read an XML Document(C#)?
body: <p>I have the following XML that I am trying to "load" into an XmlDocument object:<a href="https://maps.googleapis.com/maps/api/directions/xml?origin=Jamaica,%20NY%2011418&amp;destination=Hunter%20College%20Park%20Avenue%20New%20York&amp;mode=&amp;alternatives=true&amp;key=AIzaSyB8G9omVUu6a_OQCrRM-QItdwk-Hxq__mg" rel="nofollow">Link to XML File</a></p>
  
  <p>I have the following method piece of code to load the XML document:</p>
  
  <pre><code>public XmlDocument getDirections()
      {
          XmlTextReader xmlReader;
          XmlDocument xmlResponse = new XmlDocument();
          StringBuilder xmlResponseString = new StringBuilder();
          xmlReader = new XmlTextReader(getRequestURL()); //getRequestURL gives the URL for XML doucument
  
          while (xmlReader.Read())
          {
              if (xmlReader.NodeType == XmlNodeType.Element)
              {
                  xmlResponseString.Append(xmlReader.ReadInnerXml());
              }
          }
          xmlResponse.LoadXml(xmlResponseString.ToString());
          return xmlResponse;
       }
  </code></pre>
  
  <p>When I run the code, I get the following error:</p>
  
  <pre><code>An unhandled exception of type 'System.Xml.XmlException' occurred in System.Xml.dll
  
  Additional information: There are multiple root elements. Line 3, position 3.
  </code></pre>
  
  <p>I figured this happens because the XML document have multiple <code>route</code> objects but I don't know how to fix it. Any help would be appreciated !</p>