Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use < symbol in xml file...?
    primarykey
    data
    text
    <p>I have a XML file in assets folder.</p> <p>I am parsing it in my Activity and displaying it.</p> <p>In XML file I has a data with <code>&lt;</code> symbol, I use <code>&amp;lt;</code> <code>at</code> &lt; symbol.</p> <p>But, the symbol is not displying and text after the symbol only i am getting.</p> <p>ex <code>"hi &amp;lt; hello"</code></p> <p>parsing result will be only <code>hello</code></p> <p>parsing code</p> <pre><code>try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); SecondHandler shandler = new SecondHandler(); xr.setContentHandler(shandler); InputStream in = this.getAssets().open(fileName); xr.parse(new InputSource(in)); itemlist = shandler.getParsedData(); } catch (Exception e) { System.out.println("Error : " + e); } Map&lt;String, String&gt; item = (Map&lt;String, String&gt;) list.get(5); String qus = item.get("question"); String ans = item.get("answer"); } </code></pre> <p>xml file..</p> <pre><code>.......... &lt;dict&gt; &lt;question&gt;hello&lt;/question&gt; &lt;answer&gt;I am &amp;lt; 5 you&lt;/answer&gt; &lt;/dict&gt; ...... </code></pre> <p>handler code.</p> <pre><code>public class SecondHandler extends DefaultHandler { private String tagName; @SuppressWarnings("rawtypes") private ArrayList&lt;Map&gt; dataSet; private Map&lt;String, String&gt; dictionary; @SuppressWarnings("rawtypes") public ArrayList&lt;Map&gt; getParsedData() { return dataSet; } @Override public void startDocument() throws SAXException { } @Override public void endDocument() throws SAXException { // Nothing to do } @SuppressWarnings("rawtypes") @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { tagName = localName; if (localName.equals("array")) { this.dataSet = new ArrayList&lt;Map&gt;(); } else if (localName.equals("dict")) { dictionary = new HashMap&lt;String, String&gt;(); } } @Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if (localName.equals("array")) { } else if (localName.equals("dict")) { dataSet.add(dictionary); } } @Override public void characters(char ch[], int start, int length) { String string = new String(ch, start, length); string = string.replaceAll(" ", ""); string = string.replaceAll("\n", ""); string = string.replaceAll("\t", ""); if (string.length() &gt; 0 &amp;&amp; string != null) { dictionary.put(tagName, new String(ch, start, length)); // System.out.println("Dictionary : " + dictionary); } } } </code></pre> <p>How to solve this problem</p> <p>Thanks in advance...!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload