我试图显示,与增强功能,文本从一个XML文件中对标签内得到。以下是打开标签,文本和结束标记:设定大胆一些文本的话,从XML
<英语> <强>英语形容词:一名年轻女子< /强> </BR > 他们总是在性别和数量不变。 < /英语>但是,我看到的不仅仅是上述文字,还有<英文>和< /英文>之间的标签,<强>。如何解决这个问题?由于
这里是读取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();
}
}`
的方法和这里有点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>`
怎么样你试图显示? –
我用的方法,但我不能表现出来的:-( – Andy
此评论您可以更新您的问题,并粘贴您的方法。 –