本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.TEXT屬性的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.TEXT屬性的具體用法?Java XmlPullParser.TEXT怎麽用?Java XmlPullParser.TEXT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.xmlpull.v1.XmlPullParser
的用法示例。
在下文中一共展示了XmlPullParser.TEXT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseManifest
/**
* parseManifest
*
* @param parser parser
* @param intentFilters intentFilters
* @throws Exception e
*/
private static void parseManifest(XmlResourceParser parser, Map<String, IntentFilter> intentFilters)
throws Exception {
int outerDepth = parser.getDepth();
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
continue;
}
String tagName = parser.getName();
if (tagName == null) {
continue;
}
if (tagName.equals("activity") || tagName.equals("receiver") || tagName.equals("service")) {
String activityName = parser.getAttributeValue(ANDROID_RESOURCES, "name");
if (activityName != null) {
parseActivity(activityName, intentFilters, parser);
}
}
}
}
示例2: readImage
private static void readImage(XmlPullParser parser, SearchEngine searchEngine) throws IOException, XmlPullParserException {
parser.require(XmlPullParser.START_TAG, null, "Image");
if (parser.next() != XmlPullParser.TEXT) {
return;
}
final String uri = parser.getText();
if (!uri.startsWith(IMAGE_URI_PREFIX)) {
return;
}
final byte[] raw = Base64.decode(uri.substring(IMAGE_URI_PREFIX.length()), Base64.DEFAULT);
searchEngine.icon = BitmapFactory.decodeByteArray(raw, 0, raw.length);
parser.nextTag();
}
示例3: doWork
public void doWork(XmlPullParser reader, XMLWriter writer)
throws Exception
{
// Deal with the contents of the tag
int eventType = reader.getEventType();
while (eventType != XmlPullParser.END_TAG)
{
eventType = reader.next();
if (eventType == XmlPullParser.START_TAG)
{
ImportFileUpdater.this.outputCurrentElement(reader, writer, new OutputChildren());
}
else if (eventType == XmlPullParser.TEXT)
{
// Write the text to the output file
writer.write(reader.getText());
}
}
}
示例4: parseContentProtection
/**
* Parses a {@link ContentProtection} element.
*
* @throws XmlPullParserException If an error occurs parsing the element.
* @throws IOException If an error occurs reading the element.
* @return The parsed {@link ContentProtection} element, or null if the element is unsupported.
**/
protected ContentProtection parseContentProtection(XmlPullParser xpp)
throws XmlPullParserException, IOException {
String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri");
UUID uuid = null;
SchemeInitData data = null;
boolean seenPsshElement = false;
do {
xpp.next();
// The cenc:pssh element is defined in 23001-7:2015.
if (ParserUtil.isStartTag(xpp, "cenc:pssh") && xpp.next() == XmlPullParser.TEXT) {
seenPsshElement = true;
data = new SchemeInitData(MimeTypes.VIDEO_MP4,
Base64.decode(xpp.getText(), Base64.DEFAULT));
uuid = PsshAtomUtil.parseUuid(data.data);
}
} while (!ParserUtil.isEndTag(xpp, "ContentProtection"));
if (seenPsshElement && uuid == null) {
Log.w(TAG, "Skipped unsupported ContentProtection element");
return null;
}
return buildContentProtection(schemeIdUri, uuid, data);
}
示例5: gatherValuesForTagName
private static void gatherValuesForTagName(String tagName, Reader xml, StringBuilder gatherer, int maxSize)
throws XmlPullParserException, IOException
{
XmlPullParser parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(xml);
int event = parser.getEventType();
while( event != XmlPullParser.END_DOCUMENT )
{
if( event == XmlPullParser.START_TAG && parser.getName().equals(tagName) )
{
while( parser.next() == XmlPullParser.TEXT )
{
String s = parser.getText();
if( s != null )
{
// Removal all tabs, newlines, returns, etc.. and trim
// white space
s = s.replaceAll("\\cM?\r?\r\n\t", "").trim();
if( s.length() > 0 )
{
gatherer.append(s);
gatherer.append(' ');
}
}
}
if( gatherer.length() >= maxSize )
{
return;
}
}
event = parser.next();
}
}
示例6: next
protected NodeEvent next() throws XmlPullParserException, IOException
{
if( playback )
{
playbackIndex++;
current = history.get(playbackIndex);
}
else
{
int code = parser.next();
NodeEvent event = new NodeEvent();
event.status = code;
if( code == XmlPullParser.START_TAG )
{
event.name = parser.getName();
@SuppressWarnings("unchecked")
Pair<String, String>[] convenientDevice = new Pair[parser.getAttributeCount()];
event.attributes = convenientDevice;
for( int i = 0; i < event.attributes.length; i++ )
{
Pair<String, String> attr = new Pair<String, String>(parser.getAttributeName(i),
parser.getAttributeValue(i));
event.attributes[i] = attr;
}
}
else if( code == XmlPullParser.TEXT )
{
event.whitespace = parser.isWhitespace();
event.text = parser.getText();
}
if( recording )
{
history.add(event);
}
current = event;
}
return current;
}
示例7: parse
/**
* xml解析為對象
*
* @param text
* @return
*/
public static GradleDependencyEntity parse(String text) {
GradleDependencyEntity entity = new GradleDependencyEntity();
XmlPullParserFactory f = null;
try {
f = XmlPullParserFactory.newInstance();
f.setNamespaceAware(true);
XmlPullParser xmlPullParser = f.newPullParser();
xmlPullParser.setInput(new InputStreamReader(new ByteArrayInputStream(text.getBytes())));
int eventType = xmlPullParser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_DOCUMENT) {
} else if (eventType == XmlPullParser.START_TAG) {
String name = xmlPullParser.getName();
if (name.equals("groupId")) {
entity.setGroupId(xmlPullParser.nextText());
} else if (name.equals("artifactId")) {
entity.setArtifactId(xmlPullParser.nextText());
} else if (name.equals("version")) {
String version = xmlPullParser.nextText();
entity.setVersion(version);
} else if (name.equals("lastUpdated")) {
entity.setUpdateTime(xmlPullParser.nextText());
}
} else if (eventType == XmlPullParser.END_TAG) {
} else if (eventType == XmlPullParser.TEXT) {
}
eventType = xmlPullParser.next();
}
} catch (Exception e) {
e.printStackTrace();
}
return entity;
}
示例8: readText
private String readText(XmlPullParser parser) throws IOException, XmlPullParserException {
String result = "";
if (parser.next() == XmlPullParser.TEXT) {
result = parser.getText();
parser.nextTag();
}
android.util.Log.d("PARSE", "read text " + result);
return result;
}
示例9: readText
public static String readText(XmlPullParser parser) throws Exception
{
String result = "";
if (parser.next() == XmlPullParser.TEXT)
{
result = parser.getText();
parser.nextTag();
}
return result;
}
示例10: readInt
private int readInt(XmlPullParser parser) throws IOException, XmlPullParserException {
String result = "";
if (parser.next() == XmlPullParser.TEXT) {
result = parser.getText();
parser.nextTag();
}
return Integer.valueOf(result);
}
示例11: readXmlElementText
private String readXmlElementText(XmlPullParser parser) throws IOException, XmlPullParserException {
String result = "";
if (parser.next() == XmlPullParser.TEXT) {
result = parser.getText();
parser.nextTag();
}
if (result != null && !result.isEmpty()) {
result = result.trim();
}
return result;
}
示例12: getTag
private String getTag(String tag, String source) {
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xmlPullParser = factory.newPullParser();
xmlPullParser.setInput(new StringReader(source));
xmlPullParser.next();
int eventType = xmlPullParser.getEventType();
String content = null;
boolean shouldRead = false;
while (eventType != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_TAG:
if (xmlPullParser.getName().equals(tag)) {
shouldRead = true;
}
break;
case XmlPullParser.TEXT:
if (shouldRead) {
content = xmlPullParser.getText();
}
break;
case XmlPullParser.END_TAG:
shouldRead = false;
break;
}
eventType = xmlPullParser.next();
}
return content;
} catch (IOException | XmlPullParserException e) {
Timber.i("", e);
}
return null;
}
示例13: readText
private String readText(XmlPullParser parser) throws IOException, XmlPullParserException {
String result = "";
if (parser.next() == XmlPullParser.TEXT) {
result = parser.getText();
parser.nextTag();
}
return result;
}
示例14: readLong
private Long readLong(XmlPullParser parser) throws IOException, XmlPullParserException {
Long result = null;
if (parser.next() == XmlPullParser.TEXT) {
final String text = parser.getText();
if (text != null && !text.isEmpty()) {
result = Long.valueOf(text);
}
parser.nextTag();
}
return result;
}
示例15: readText
private String readText(@NonNull XmlPullParser parser)
throws IOException, XmlPullParserException {
String text = "";
if (parser.next() == XmlPullParser.TEXT) {
text = parser.getText();
parser.next();
}
return text;
}