Android - xml ampersand conversion
<p>I have a sax parser with an xml tag that contains the following text: "A &amp; amp; B" (There's no space there - added so it will not convert to &amp; here)</p>

<p>It's as though it's getting converted twice and escaping due to ampersand with a result of "A". Here's the process:</p>

<p>Xml file is downloaded</p>

<pre><code>InputStream _inputStream = _urlConnection.getInputStream();
                        BufferedInputStream _bufferedInputStream = new BufferedInputStream(_inputStream);
                        ByteArrayBuffer _byteArrayBuffer = new ByteArrayBuffer(64);

                        int current = 0;
                        while((current = _bufferedInputStream.read()) != -1)
                        {
                            _byteArrayBuffer.append((byte)current);
                        }

                        FileOutputStream _fileOutputStream = openFileOutput(_file, MODE_PRIVATE);

                        _fileOutputStream.write(_byteArrayBuffer.toByteArray());
                        _fileOutputStream.close();
</code></pre>

<p>Data is converted with Sax in the endElement</p>

<pre><code>else if (inLocalName.equalsIgnoreCase(_nodeTitle))
        {
            _titleValue = currentValue;
            currentValue = "";
        }
</code></pre>

<p>In debug, the ampersand is already converted and the data truncated when I read it in my characters method in the handler.</p>

<p>I've seen a lot of questions about this but never a solution. Any ideas?</p>

<p>Thanks</p>

<p>Parser:</p>

<pre><code>List&lt;PropertiesList&gt; _theList = null;

        try 
        {
            // Create Factory, Parser, Reader, Handler
            SAXParserFactory _saxParserFactory = SAXParserFactory.newInstance();
            SAXParser _saxParser = _saxParserFactory.newSAXParser();
            XMLReader _xmlReader = _saxParser.getXMLReader();
            HandlerReps _handler = new HandlerReps(inRegion, inAbbreviation);

            _xmlReader.setContentHandler(_handler);
            _xmlReader.parse(new InputSource(inStream));

            _theList = _handler.getTheList();
        } 
</code></pre>

<p>Handler:</p>

<pre><code>// Called when Tag Begins
    @Override
    public void startElement(String uri, String inLocalName, String inQName, Attributes inAttributes) throws SAXException 
    {
        currentElement = false;
    }

    // Called when Tag Ends
    @Override
    public void endElement(String inUri, String inLocalName, String inQName) throws SAXException 
    {
        currentElement = false;

        // Title
        if (inLocalName.equalsIgnoreCase(_nodeValue))
        {
            if (_stateValue.equalsIgnoreCase(_abbreviation) &amp;&amp; 
                _countryValue.equalsIgnoreCase(_region))
            {
                // Construct the object
                PropertiesRegion _regionObject = new PropertiesRegion(_titleValue, _address1Value);

                cList.add(_regionObject);

                Log.d(TAG, _regionObject.toString());
            }

            _titleValue = "";
            _address1Value = "";
        }

        // Title
        else if (inLocalName.equalsIgnoreCase(_nodeTitle))
        {
            _titleValue = currentValue;
            currentValue = "";
        }

        // Address1
        else if (inLocalName.equalsIgnoreCase(_nodeAddress1))
        {
            _address1Value = currentValue;
            currentValue = "";
        }
    }

    // Called to get Tag Characters
    @Override
    public void characters(char[] inChar, int inStart, int inLength) throws SAXException 
    {
        if (currentElement) 
        {
            currentValue = new String(inChar, inStart, inLength);
            currentElement = false;
        }
    }
</code></pre>
