XML中的事件和標籤有什麼區別?xml中的事件和標籤之間的區別
事件是否像大標題和標籤是字幕?
我怎麼知道哪個是事件,哪個是標籤?
因此,在下面的代碼中,我從這個XML文件中獲取事件和標籤。
我看到標籤在某種程度上埋在XML文件中爲每一個事件,它正在經歷的標籤,但我想知道如何告訴兩個
public boolean process(){
boolean status = true;
Application currentRecord = null;
boolean inEntry = false;
String textValue = "";
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance().newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(new StringReader(this.xmlData));
int eventType = xpp.getEventType();
while(eventType != XmlPullParser.END_DOCUMENT){
String tagName = xpp.getName();
switch (eventType){
case XmlPullParser.START_TAG:
Log.d("ParseApplications", "Starting Tag for " + tagName);
if (tagName.equalsIgnoreCase("entry")) {
inEntry = true;
currentRecord = new Application();
}
break;
case XmlPullParser.TEXT:
textValue = xpp.getText();
break;
case XmlPullParser.END_TAG:
Log.d("ParseApplication", "Ending Tag for " + tagName);
if (inEntry){
if (tagName.equalsIgnoreCase("entry")){
applications.add(currentRecord);
inEntry = false;
}
else if (tagName.equalsIgnoreCase("name")){
currentRecord.setName(textValue);
}
else if (tagName.equalsIgnoreCase("artist")){
currentRecord.setArtist(textValue);
}
else if (tagName.equalsIgnoreCase("release date")){
currentRecord.setReleaseDate(textValue);
}
}
break;
default :
}
eventType = xpp.next();
示例代碼將不勝感激...... –
@chalarangelo added – Jchoi