當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlPullParser.getText方法代碼示例

本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.getText方法的具體用法?Java XmlPullParser.getText怎麽用?Java XmlPullParser.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xmlpull.v1.XmlPullParser的用法示例。


在下文中一共展示了XmlPullParser.getText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processMetaData

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
 * Process meta-data
 * 
 * @param xpp XmlPullParser
 * @param metaDataName QName
 * @param parserContext ParserContext
 * @throws XmlPullParserException
 * @throws IOException
 */
private void processMetaData(XmlPullParser xpp, QName metaDataName, ParserContext parserContext)
    throws XmlPullParserException, IOException
{
    MetaDataContext metaData = (MetaDataContext)parserContext.elementStack.peek();

    String value = null;
    
    int eventType = xpp.next();
    if (eventType == XmlPullParser.TEXT)
    {
        // Extract value
        value = xpp.getText();
        eventType = xpp.next();
    }
    if (eventType != XmlPullParser.END_TAG)
    {
        throw new ImporterException("Meta data element " + metaDataName + " is missing end tag");
    }

    metaData.setProperty(metaDataName, value);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:31,代碼來源:ViewParser.java

示例2: getPITarget

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static String getPITarget(XmlPullParser var0) throws IllegalStateException {
   int var1;
   try {
      var1 = var0.getEventType();
   } catch (XmlPullParserException var4) {
      throw new IllegalStateException("could not determine parser state: " + var4 + var0.getPositionDescription());
   }

   if(var1 != 8) {
      throw new IllegalStateException("parser must be on processing instruction and not " + XmlPullParser.TYPES[var1] + var0.getPositionDescription());
   } else {
      String var2 = var0.getText();

      for(int var3 = 0; var3 < var2.length(); ++var3) {
         if(isS(var2.charAt(var3))) {
            return var2.substring(0, var3);
         }
      }

      return var2;
   }
}
 
開發者ID:imkiva,項目名稱:AndroidApktool,代碼行數:23,代碼來源:XmlPullUtil.java

示例3: f

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static String f(XmlPullParser xmlPullParser) {
    String str = "";
    int depth = xmlPullParser.getDepth();
    while (true) {
        if (xmlPullParser.next() == 3 && xmlPullParser.getDepth() == depth) {
            return str;
        }
        str = str + xmlPullParser.getText();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:c.java

示例4: readValueXml

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
 * Read a flattened object from an XmlPullParser.  The XML data could
 * previously have been written with writeMapXml(), writeListXml(), or
 * writeValueXml().  The XmlPullParser must be positioned <em>at</em> the
 * tag that defines the value.
 *
 * @param parser The XmlPullParser from which to read the object.
 * @param name An array of one string, used to return the name attribute
 *             of the value's tag.
 *
 * @return Object The newly generated value object.
 *
 * @see #readMapXml
 * @see #readListXml
 * @see #writeValueXml
 */
public static final Object readValueXml(XmlPullParser parser, String[] name)
throws XmlPullParserException, java.io.IOException
{
    int eventType = parser.getEventType();
    do {
        if (eventType == parser.START_TAG) {
            return readThisValueXml(parser, name, null, false);
        } else if (eventType == parser.END_TAG) {
            throw new XmlPullParserException(
                "Unexpected end tag at: " + parser.getName());
        } else if (eventType == parser.TEXT) {
            throw new XmlPullParserException(
                "Unexpected text: " + parser.getText());
        }
        eventType = parser.next();
    } while (eventType != parser.END_DOCUMENT);

    throw new XmlPullParserException(
        "Unexpected end of document");
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:37,代碼來源:XmlUtils.java

示例5: getText

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static String getText(XmlPullParser xpp) throws XmlPullParserException, IOException {
    int eventType = xpp.next();
    if (eventType != XmlPullParser.TEXT) {
        return "";
    }
    return xpp.getText();
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:8,代碼來源:SettingsImporter.java

示例6: readText

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
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;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:10,代碼來源:PropfindXmlParser.java

示例7: readText

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
String readText(XmlPullParser parser) throws IOException, XmlPullParserException {
    String result = "";
    if (parser.next() == XmlPullParser.TEXT) {
        result = parser.getText();
        parser.nextTag();
    }
    return result;
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:9,代碼來源:Telemetry.java

示例8: readText

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private String readText(XmlPullParser parser) throws IOException, XmlPullParserException {
    String result = "";
    if (parser.next() == XmlPullParser.TEXT) {
        result = parser.getText();
        parser.nextTag();
    }
    return result;
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:9,代碼來源:StackOverflowXmlParser.java

示例9: readDouble

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private double readDouble(XmlPullParser parser) throws IOException, XmlPullParserException {
    String result = "";
    if (parser.next() == XmlPullParser.TEXT) {
        result = parser.getText();
        parser.nextTag();
    }
    return Double.valueOf(result);
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:9,代碼來源:StackOverflowXmlParser.java

示例10: readInt

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private int readInt(XmlPullParser parser) throws IOException, XmlPullParserException {
    String result = "";
    if (parser.next() == XmlPullParser.TEXT) {
        result = parser.getText();
        parser.nextTag();
    }
    return Integer.valueOf(result);
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:9,代碼來源:StackOverflowXmlParser.java

示例11: readShortName

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static void readShortName(XmlPullParser parser, SearchEngine searchEngine) throws IOException, XmlPullParserException {
    parser.require(XmlPullParser.START_TAG, null, "ShortName");
    if (parser.next() == XmlPullParser.TEXT) {
        searchEngine.name = parser.getText();
        parser.nextTag();
    }
}
 
開發者ID:mozilla-mobile,項目名稱:firefox-tv,代碼行數:8,代碼來源:SearchEngineParser.java

示例12: readText

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private String readText(@NonNull XmlPullParser parser) throws IOException, XmlPullParserException {
    String result = "";

    if (parser.next() == XmlPullParser.TEXT) {
        result = parser.getText();
        parser.nextTag();
    }

    return result;
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-MediaServer,代碼行數:11,代碼來源:RssParser.java

示例13: gatherValuesForTagName

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
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();
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:37,代碼來源:AbstractOffice2007Extracter.java

示例14: getTag

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
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;
}
 
開發者ID:mecid,項目名稱:robird-reborn,代碼行數:37,代碼來源:TweetLongerUtils.java

示例15: readFeed

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
 * Read and analyze RSS feed.
 *
 * @param parser the XML parser with some objects to be classified
 * @return a list of well formed news that can be clicked later inside {@link org.mbach.lemonde.article.ArticleActivity}
 */
@NonNull
private ArrayList<RssItem> readFeed(@NonNull XmlPullParser parser) {
    ArrayList<RssItem> items = new ArrayList<>();
    RssItem item = new RssItem();
    String text = null;
    /// TODO: store cache calls maybe here!
    try {
        while (parser.next() != XmlPullParser.END_DOCUMENT) {

            String tagName = parser.getName();
            switch (parser.getEventType()) {
                case XmlPullParser.START_TAG:
                    if (tagName.equalsIgnoreCase(TAG_ITEM)) {
                        item = new RssItem();
                    }
                    break;
                case XmlPullParser.TEXT:
                    text = parser.getText();
                    break;
                case XmlPullParser.END_TAG:
                    if (tagName.equalsIgnoreCase("item")) {
                        items.add(item);
                    } else if (tagName.equalsIgnoreCase(TAG_LINK)) {
                        item.setLink(text);
                    } else if (tagName.equalsIgnoreCase(TAG_TITLE)) {
                        item.setTitle(text);
                    } else if (tagName.equalsIgnoreCase(TAG_ENCLOSURE)) {
                        text = parser.getAttributeValue(null, "url");
                        item.setEnclosure(text);
                    }
                    break;
                default:
                    break;
            }
        }
    } catch (XmlPullParserException | IOException e ) {
        Log.e(TAG, "The stream cannot be parsed! Is it really well-formed? " + e.getMessage());
    }
    return items;
}
 
開發者ID:MBach,項目名稱:LeMondeRssReader,代碼行數:47,代碼來源:RssParser.java


注:本文中的org.xmlpull.v1.XmlPullParser.getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。