本文整理汇总了Java中org.kxml2.io.KXmlParser.nextTag方法的典型用法代码示例。如果您正苦于以下问题:Java KXmlParser.nextTag方法的具体用法?Java KXmlParser.nextTag怎么用?Java KXmlParser.nextTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kxml2.io.KXmlParser
的用法示例。
在下文中一共展示了KXmlParser.nextTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processSurveyList
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
public void processSurveyList(KXmlParser parser, Hashtable formInfo) throws XmlPullParserException{
try {
//boolean inItem = false;
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, "forms");
while( parser.nextTag() != XmlPullParser.END_TAG ){
//parser file names
parser.require(XmlPullParser.START_TAG, null, null);
String name = parser.getName();
String url = parser.getAttributeValue(null, "url");
String text = parser.nextText();
if(name.equals("form"))
{
//inItem = true;
//items.addElement(text);
formInfo.put(text, url);
}
else
//inItem = false;
parser.require(XmlPullParser.END_TAG, null, "form");
}
parser.require(XmlPullParser.END_TAG, null, "forms");
parser.next();
parser.require(XmlPullParser.END_DOCUMENT, null, null);
} catch (IOException e) {
// TODO: handle exception
System.out.println("XML parser error");
e.printStackTrace();
}
}
示例2: readTestSuite
import org.kxml2.io.KXmlParser; //导入方法依赖的package包/类
private Collection<Outcome> readTestSuite(KXmlParser parser)
throws XmlPullParserException, IOException {
Collection<Outcome> outcomes = new ArrayList<Outcome>();
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, XmlReportConstants.TESTSUITE);
Map<String, String> testSuiteAttributes = createAttributeMap(parser);
String timestamp = testSuiteAttributes.get(XmlReportConstants.TIMESTAMP);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, XmlReportConstants.PROPERTIES);
parser.nextTag();
parser.require(XmlPullParser.END_TAG, null, XmlReportConstants.PROPERTIES);
while (parser.nextTag() == XmlPullParser.START_TAG) {
parser.require(XmlPullParser.START_TAG, null, XmlReportConstants.TESTCASE);
Map<String, String> testCaseAttributes = createAttributeMap(parser);
String name = testCaseAttributes.get(XmlReportConstants.ATTR_NAME);
String classname = testCaseAttributes.get(XmlReportConstants.ATTR_CLASSNAME);
Result result = Result.SUCCESS;
String resultOutput = null;
parser.nextTag();
String tagName = parser.getName();
if (resultTagNames.contains(tagName)) {
parser.require(XmlPullParser.START_TAG, null, tagName);
Map<String, String> resultAttributes = createAttributeMap(parser);
String type = resultAttributes.get(XmlReportConstants.ATTR_TYPE);
result = Result.valueOf(type);
resultOutput = parser.nextText();
parser.require(XmlPullParser.END_TAG, null, tagName);
parser.nextTag();
}
// create outcome!
SimpleDateFormat dateFormat = new SimpleDateFormat(XmlReportConstants.DATEFORMAT);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
dateFormat.setLenient(true);
Date date;
try {
date = dateFormat.parse(timestamp);
} catch (ParseException e) {
throw new RuntimeException(e);
}
outcomes.add(new Outcome(classname + "#" + name, result, resultOutput, date));
parser.require(XmlPullParser.END_TAG, null, XmlReportConstants.TESTCASE);
}
parser.require(XmlPullParser.END_TAG, null, XmlReportConstants.TESTSUITE);
return outcomes;
}