title: load values of ArrayList file into a ArrayList
body: <p>I'm trying to load the data of ArrayList file into ArrayList, but i got this exception error:</p>
  
  <pre><code>07-07 16:52:21.741: W/System.err(1941): org.xml.sax.SAXParseException: Unexpected token (position:TEXT [Ljava.lang.Stri...@1:28 in java.io.StringReader@f7179f5) 
  07-07 16:52:21.741: W/System.err(1941):     at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:146)
  07-07 16:52:21.743: W/System.err(1941):     at com.example.ActivityQuizScreen.addflags(ActivityQuizScreen.java:253)
  07-07 16:52:21.743: W/System.err(1941):     at com.example.ActivityQuizScreen.onCreate(ActivityQuizScreen.java:108)
  07-07 16:52:21.743: W/System.err(1941):     at android.app.Activity.performCreate(Activity.java:6237)
  07-07 16:52:21.743: W/System.err(1941):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
  07-07 16:52:21.745: W/System.err(1941):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
  07-07 16:52:21.745: W/System.err(1941):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
  07-07 16:52:21.745: W/System.err(1941):     at android.app.ActivityThread.-wrap11(ActivityThread.java)
  07-07 16:52:21.745: W/System.err(1941):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
  07-07 16:52:21.746: W/System.err(1941):     at android.os.Handler.dispatchMessage(Handler.java:102)
  07-07 16:52:21.746: W/System.err(1941):     at android.os.Looper.loop(Looper.java:148)
  07-07 16:52:21.746: W/System.err(1941):     at android.app.ActivityThread.main(ActivityThread.java:5417)
  07-07 16:52:21.747: W/System.err(1941):     at java.lang.reflect.Method.invoke(Native Method)
  07-07 16:52:21.747: W/System.err(1941):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  07-07 16:52:21.747: W/System.err(1941):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  07-07 16:52:21.877: W/EGL_emulation(1941): eglSurfaceAttrib not implemented
  07-07 16:52:21.877: W/OpenGLRenderer(1941): Failed to set EGL_SWAP_BEHAVIOR on surface 0xac0b28c0, error=EGL_SUCCESS
  07-07 16:52:22.429: E/Surface(1941): getSlotFromBufferLocked: unknown buffer: 0xabff43b0
  07-07 16:53:21.877: W/EGL_emulation(1941): eglSurfaceAttrib not implemented
  07-07 16:53:21.880: W/OpenGLRenderer(1941): Failed to set EGL_SWAP_BEHAVIOR on surface 0xac0b2ee0, error=EGL_SUCCESS
  </code></pre>
  
  <p>the code is :</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  private void addflags() throws ParserConfigurationException, SAXException, IOException{
  
      ArrayList&lt;Flag&gt; flagList = new ArrayList&lt;Flag&gt;();
  
      DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      InputSource source = new InputSource();
      source.setCharacterStream(new StringReader((getResources().getStringArray(R.array.flags)).toString()));
      org.w3c.dom.Document doc = db.parse(source);  // ActivityQuizScreen.java:253 is about here
      NodeList nodes = doc.getElementsByTagName("item");
      for(int i = 0; i&lt; nodes.getLength();i++)
      {               
         NamedNodeMap attr = nodes.item(i).getAttributes();
  
         String name = attr.getNamedItem("name").getNodeValue();
         String CountryCode = attr.getNamedItem("pic").getNodeValue().toLowerCase();
      int pic = getResources().getIdentifier(CountryCode, "drawable", getPackageName());
      Flag flag = new Flag(
              attr.getNamedItem("name").getNodeValue(),
              getResources().getIdentifier(CountryCode, "drawable", getPackageName()));
      flagList.add(flag);
  
      }
  </code></pre>
  
  <p>Array list file is like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;string-array name="flags"&gt; 
      &lt;item pic="AF"  name="Afghanistan"  /&gt;
      &lt;item pic="AL"  name="Albania"  /&gt;
      &lt;item pic="DZ"  name="Algeria"  /&gt;
      &lt;item pic="AS"  name="American Samoa"  /&gt;
      &lt;item pic="AD"  name="Andorra"  /&gt;
      :               :                :
      &lt;item pic="YE"  name="Yemen"  /&gt;
      &lt;item pic="ZM"  name="Zambia"  /&gt;
      &lt;item pic="ZW"  name="Zimbabwe"  /&gt;
      &lt;item pic="AX"  name="Åland Islands"  /&gt;
  
  &lt;/string-array&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>How i can solve this, or is there better solutions to load arrayl list from a file?? Anyone plzzzzzz?</p>
  
  <p>Thank you!!</p>