本文整理匯總了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);
}
示例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;
}
}
示例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();
}
}
示例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");
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}