我正在使用StAX来处理巨大的xml文件。如下面的代码所示,在switch-case中有一个默认条件。当我运行代码 默认情况下的文本打印以下内容:
unhandled case4
case4是什么?我试图为Stax的java文档,但我找不到它......似乎XMLStreamConstants.START_ELEMENT的常量int值为1 和XMLStreamConstants.END_ELEMENT的常量值为2 ......但是哪一个是4?
码:
for (int event = mStAXParser.next(); event != XMLStreamConstants.END_DOCUMENT; event = mStAXParser.next()) {
switch (event) {
case XMLStreamConstants.START_ELEMENT:
Log.d(TAG, "main", "@START_ELEMENT");
Log.d(TAG, "main", "getLocalName(): "+mStAXParser.getLocalName());
Log.d(TAG, "main", "getAttributeCount(): "+mStAXParser.getAttributeCount());
Log.d(TAG, "main", "getAttributeLocalName(): "+mStAXParser.getAttributeLocalName(1));
Log.d(TAG, "main", "getAttributeValue(): "+mStAXParser.getAttributeValue(0));
break;
case XMLStreamConstants.END_ELEMENT:
Log.d(TAG, "main", "@END_ELEMENT");
Log.d(TAG, "main", "getLocalName():"+mStAXParser.getLocalName());
break;
default:
Log.wtf(TAG, "main", "unhandled case" + event);
}
}
答案 0 :(得分:2)