title: Handle special character for XML Data to parse in Java
body: <p>I just learn how to working with ListView and parsing XML data in Java following this <a href="http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/" rel="nofollow">tutorial</a>. However, I'm getting an error because the XML data contains some special characters. Could someone kindly advice me on this issue?</p>
  
  <p>This is my XML Data looks like.</p>
  
  
  
  <pre><code>&lt;menu&gt;
  
  &lt;item&gt;      
      &lt;id&gt;1&lt;/id&gt;
      &lt;question&gt;What's my phone number?&lt;/question&gt;
      &lt;answer&gt;my phone number is "000-000-0000".&lt;/answer&gt;        
  &lt;/item&gt;  
  
  &lt;item&gt;      
      &lt;id&gt;2&lt;/id&gt;
      &lt;question&gt;What's my fax number?&lt;/question&gt;
      &lt;answer&gt;my fax number is "000-000-0000"&lt;/answer&gt;        
  &lt;/item&gt;  
  
  &lt;item&gt;      
      &lt;id&gt;3&lt;/id&gt;
      &lt;question&gt;What's my mailing address?&lt;/question&gt;
      &lt;answer&gt;my address here&lt;/answer&gt;        
  &lt;/item&gt; 
  
  &lt;item&gt;      
      &lt;id&gt;4&lt;/id&gt;
      &lt;question&gt;What's my web address?&lt;/question&gt;
      &lt;answer&gt;https://mywebsite.com/Login/Login.aspx?cID=53044&amp;lng=en-US&lt;/answer&gt;        
  &lt;/item&gt; 
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>And here is the Java class.</p>
  
  <pre><code>public class FaqsQuestionsActivity extends ListActivity {
  
  
      static final String URL = "http://myweb.com/faq_list.xml";
      // XML node keys
      static final String KEY_ITEM = "item"; // parent node   
      static final String KEY_ID = "id";
      static final String KEY_QUESTION = "question";
      static final String KEY_ANSWER = "answer";
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.faqs_questions);
  
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; menuItems = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
          XMLParser parser = new XMLParser();
          String xml = parser.getXmlFromUrl(URL); // getting XML
          Document doc = parser.getDomElement(xml); // getting DOM element
  
          NodeList nl = doc.getElementsByTagName(KEY_ITEM);
  
          for (int i = 0; i &lt; nl.getLength(); i++) {
  
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
              Element e = (Element) nl.item(i);
  
              map.put(KEY_ID, parser.getValue(e, KEY_ID));
              map.put(KEY_QUESTION, parser.getValue(e, KEY_QUESTION ));
              map.put(KEY_ANSWER, parser.getValue(e, KEY_ANSWER));
  
              menuItems.add(map);
          }
  
          ListAdapter adapter = new SimpleAdapter(this, menuItems, R.layout.faqs_question_list,
          new String[] { KEY_QUESTION, KEY_ANSWER  }, new int[] {R.id.question, R.id.answer});
  
  
          setListAdapter(adapter);
  
          ListView lv = getListView();
  
          lv.setOnItemClickListener(new OnItemClickListener() {
  
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
  
                  String question = ((TextView) view.findViewById(R.id.question)).getText().toString();
                  String answer = ((TextView) view.findViewById(R.id.answer)).getText().toString();
  
  
                  Intent in = new Intent(getApplicationContext(), FaqsAnswersActivity.class);
  
                  in.putExtra(KEY_QUESTION, question);
                  in.putExtra(KEY_ANSWER, answer);
                  startActivity(in);
  
              }
          });
      }
  }
  </code></pre>