I am trying to display, with enhancements, a text taken from inside a pair of tags in an XML file. Here are the opening tag, the text, and the closing tag:
<english><strong>English adjectives: a young woman</strong></br> They are always invariable in gender and number.</english>
But instead of viewing the enhanced text, all I see is exactly the above text between the <english>
and </english>
tags, with the things like <strong>
included. How can I solve this?
Here is the method to read the XML file:
public void lireXML(String mot)
throws XmlPullParserException, IOException
{
final TextView monMessage = (TextView) findViewById(R.id.zone_trado_scrollable);
XmlResourceParser monFichierXML = getResources().getXml(R.xml.text);
monFichierXML.next();
int eventType = monFichierXML.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT)
{
if( (eventType == XmlPullParser.START_TAG) && (monFichierXML.getName().equalsIgnoreCase("word")) )
{
monFichierXML.next();
if ( monFichierXML.getText().equalsIgnoreCase(mot) )
{
monFichierXML.nextTag(); // word fermant
monFichierXML.nextTag(); // english ouvrant
monFichierXML.next(); // texte anglais
if (langueChoisie == "francais") {
monFichierXML.nextTag(); // english fermant
monFichierXML.nextTag(); // français ouvrant
monFichierXML.next(); // texte français
}
if (langueChoisie == "espanol") {
monFichierXML.nextTag(); // english fermant
monFichierXML.nextTag(); // français ouvrant
monFichierXML.next(); // texte français
monFichierXML.nextTag(); // français fermant
monFichierXML.nextTag(); // espanol ouvrant
monFichierXML.next(); // texte espanol
}
if (langueChoisie == "chinois") {
monFichierXML.nextTag(); // english fermant
monFichierXML.nextTag(); // français ouvrant
monFichierXML.next(); // texte français
monFichierXML.nextTag(); // français fermant
monFichierXML.nextTag(); // espanol ouvrant
monFichierXML.next(); // texte espanol
monFichierXML.nextTag(); // espagnol fermant
monFichierXML.nextTag(); // russe ouvrant
monFichierXML.next(); // texte russe
monFichierXML.nextTag(); // russe fermant
monFichierXML.nextTag(); // chinois ouvrant
monFichierXML.next(); // texte chinois
}
// on affiche le texte à l'intérieur de la balise sélectionnée
monMessage.setText(monFichierXML.getText());
}
}
eventType = monFichierXML.next();
}
}`
And here is a bit of XML:
<group>
<word>young1</word>
<english><strong>English adjectives: a young woman</strong> <br>They are always invariable in gender and number.</english>
<francais><strong>Les adjectifs: a young woman</strong> <br>Les adjectifs qualificatifs anglais sont invariables. Quand ils sont épithètes, ils se placent avant le substantif: a young woman. Quand ils sont attributs, ils se placent après le verbe: the woman is young.</francais>
<espanol><strong>Los adjetivos: a young woman</strong> <br>Los adjetivos en inglés son invariables. Cuando son calificativos, se colocan delante del sustantivo: a young woman. Cuando son atributos, se colocan después del verbo: the woman is young.</espanol>
<chinois><strong>英语形容词:一位年轻的女士。</strong> <br>不论性别和数量都一样</chinois>
</group>`