Reputation: 4562
In my android application I read xml files and store those data in SQLite database. When I read a record that consists "&" mark it doesn't take entire text.
for example when I read the value in the following tag it only read the 49°38. The other part is loss.
<latitude> 49°38'59''N </latitude>
in the following instance it only take only get "John Levis" part and the characters after "&" are loss.
<name> John Levis & sons</name>
Does anyone have an idea to read the entire value ???
this is how I take the value from the XML handler class that extends the DefaultHandler.[this value take in the endElement methgod]
@Override
public void characters(char[] ch, int start, int length)throws SAXException
{
super.characters(ch, start, length);
if(currentElement)
{
currentValue = new String(ch, start, length);
currentElement = false;
}
}
Upvotes: 1
Views: 660
Reputation: 163585
The characters() callback in SAX is allowed to split a text node into as many small pieces as it likes. You should accumulate them and process them when you hit the end of the text (typically an endElement event, perhaps a startElement event in mixed content). Many parsers split the text when they hit an entity reference, but they are allowed to split it anywhere.
Upvotes: 1
Reputation: 215
& should be encoded as & for the purposes of xml. Could you add the header of your xml file so we can see the encoding?
Upvotes: 0