Methods Summary |
---|
public static java.lang.String | extractChildText(org.xmlpull.v1.XmlPullParser parser)Extracts the child text for the current element in the pull parser.
// TODO: check that the current node is an element?
int eventType = parser.next();
if (eventType != XmlPullParser.TEXT) {
return null;
}
return parser.getText();
|
public static java.lang.String | extractFirstChildTextIgnoreRest(org.xmlpull.v1.XmlPullParser parser)
int parentDepth = parser.getDepth();
int eventType = parser.next();
String child = null;
while (eventType != XmlPullParser.END_DOCUMENT) {
int depth = parser.getDepth();
if (eventType == XmlPullParser.TEXT) {
if (child == null) {
child = parser.getText();
}
} else if (eventType == XmlPullParser.END_TAG && depth == parentDepth) {
return child;
}
eventType = parser.next();
}
throw new XmlPullParserException("End of document reached; never saw expected end tag at "
+ "depth " + parentDepth);
|
public static java.lang.String | nextDirectChildTag(org.xmlpull.v1.XmlPullParser parser, int parentDepth)
int targetDepth = parentDepth + 1;
int eventType = parser.next();
while (eventType != XmlPullParser.END_DOCUMENT) {
int depth = parser.getDepth();
if (eventType == XmlPullParser.START_TAG && depth == targetDepth) {
return parser.getName();
}
if (eventType == XmlPullParser.END_TAG && depth == parentDepth) {
return null;
}
eventType = parser.next();
}
throw new XmlPullParserException("End of document reached; never saw expected end tag at "
+ "depth " + parentDepth);
|