title: Unexpected token (<) using Document builder in Android Studio
body: <p>I'm using document builder and NodeList in Android Studio to parse an xml document. I previously found that the xml was incorrect and had un-escaped ampersands within the text. After taking care of this though and double check with w3 XML validator, I still get an unexpected token error: </p>
  
  <blockquote>
    <p>e: "org.xml.sax.SAXParseException: Unexpected token (position:TEXT \n \n   601\n ...@5262:1 in java.io.StringReader@cd0db4a)"</p>
  </blockquote>
  
  <p>However, when I open the xml and look at the line referred to, I don't see anything that would be considered troublesome:</p>
  
  <pre><code>...  ...
  5257 &lt;WebSvcLocation&gt;
  5258 &lt;Id&gt;1521981&lt;/Id&gt;
  5259 &lt;Name&gt;Warehouse: Row 3&lt;/Name&gt;
  5260 &lt;SiteName&gt;Warehouse&lt;/SiteName&gt;
  5261 &lt;/WebSvcLocation&gt;
  5262 &lt;/ArrayOfWebSvcLocation&gt;
  </code></pre>
  
  <p>I have checked the xml as well for non printing characters and I have not found any. Below is the code I have been using:</p>
  
  <pre><code>public List&lt;Location&gt; SpinnerXML(String xml){
      List&lt;Location&gt; list = new ArrayList&lt;Location&gt;();
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder;
      InputSource is;
      String s = xml.replaceAll("[&amp;]"," and ");
  
      try {
          builder = factory.newDocumentBuilder();
          is = new InputSource(new StringReader(s));
          Document doc = builder.parse(is);
          NodeList lt = doc.getElementsByTagName("WebSvcLocation");
          int id;
          String name,siteName;
  
          for (int i = 0; i &lt; lt.getLength(); i++) {
              Element el = (Element) lt.item(i);
              id = Integer.parseInt(getValue(el, "Id"));
              name = getValue(el, "Name");
              siteName = getValue(el, "SiteName");
  
              list.add(new Location(id, name, siteName));
          }
  
      } catch (ParserConfigurationException e){
      } catch (SAXException e){
          e.printStackTrace();
      } catch (IOException e){
      }
  
      return list;
  }
  </code></pre>
  
  <p>The XML I have been trying to read is hosted <a href="http://text-share.com/view/7b1c6918" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Thanks in advance for the help!</p>