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


Java XmlPullParserFactory.setNamespaceAware方法代碼示例

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


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

示例1: Dsmlv2Parser

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * Creates a new instance of Dsmlv2Parser.
 *
 * @param storeMsgInBatchReq flag to set if the parsed requests should b stored
 * @throws XmlPullParserException if an error occurs during the initialization of the parser
 */
public Dsmlv2Parser( boolean storeMsgInBatchReq ) throws XmlPullParserException
{
    this.storeMsgInBatchReq = storeMsgInBatchReq;

    this.grammar = new Dsmlv2Grammar();
    this.container = new Dsmlv2Container( grammar.getLdapCodecService() );

    this.container.setGrammar( grammar );

    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware( true );
    XmlPullParser xpp = factory.newPullParser();

    container.setParser( xpp );
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:22,代碼來源:Dsmlv2Parser.java

示例2: getXmlPullParser

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
public static XmlPullParser getXmlPullParser(Resources resources, String packageName, String file) throws XMLNotFoundException, XmlPullParserException {

        XmlPullParser xpp = null;

        int xmlId = resources.getIdentifier(file, DEF_XML, packageName);

        if (xmlId > 0) {
            xpp = resources.getXml(xmlId);
        } else {
            // no resource found, try to open it from assets folder
            try {
                InputStream appfilterstream = resources.getAssets().open(file + EXT_XML);

                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                factory.setNamespaceAware(true);
                xpp = factory.newPullParser();
                xpp.setInput(appfilterstream, UTF_8);
            } catch (IOException e) {
                throw new XMLNotFoundException(file + EXT_XML, e);
            }
        }
        return xpp;
    }
 
開發者ID:sofakingforever,項目名稱:IconPackParser-Android,代碼行數:24,代碼來源:XmlPullParserGenerator.java

示例3: i

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
private void i() {
    XmlPullParser newPullParser;
    InputStream open;
    try {
        XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance();
        newInstance.setNamespaceAware(true);
        newPullParser = newInstance.newPullParser();
        open = this.b.getAssets().open("ShareSDK.xml");
    } catch (Throwable th) {
        Ln.e(th);
        return;
    }
    newPullParser.setInput(open, Constants.UTF_8);
    for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.next()) {
        if (eventType == 2) {
            String name = newPullParser.getName();
            HashMap hashMap = new HashMap();
            int attributeCount = newPullParser.getAttributeCount();
            for (eventType = 0; eventType < attributeCount; eventType++) {
                hashMap.put(newPullParser.getAttributeName(eventType), newPullParser.getAttributeValue(eventType).trim());
            }
            this.c.put(name, hashMap);
        }
    }
    open.close();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:27,代碼來源:k.java

示例4: parse

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
Podcasts parse(InputStream input, @Nullable String charset, String baseUri) throws IOException {
    try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(false);

        XmlPullParser xpp = factory.newPullParser();
        xpp.setInput(input, charset);

        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String tag = xpp.getName();
                if (LayoutUtils.isDiv(tag) && hasClass(xpp, PODCAST_LIST_CLASS)) {
                    return parsePodcasts(xpp, NetworkUtils.toOptURI(baseUri));
                }
            }
            eventType = lenientNext(xpp);
        }
        return new Podcasts();
    } catch (XmlPullParserException e) {
        throw new IOException(e);
    }
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:25,代碼來源:PodcastsLayoutParser.java

示例5: getApplicationName

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * get application name
 *
 * @param apkPath apkPath
 * @return String
 */
public static String getApplicationName(String apkPath) {
    if (apkPath == null || "".equals(apkPath)) {
        return null;
    }
    try {
        ZipFile zipFile = new ZipFile(new File(apkPath), ZipFile.OPEN_READ);
        ZipEntry manifestXmlEntry = zipFile.getEntry(ApkManifestReader.DEFAULT_XML);
        String manifestXML = ApkManifestReader.getManifestXMLFromAPK(zipFile, manifestXmlEntry);
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser parser = factory.newPullParser();
        parser.setInput(new StringReader(manifestXML));
        String applicationName = parseApplicationNameByManifest(parser);
        return applicationName;
    } catch (Exception e1) {
    }
    return "";
}
 
開發者ID:LiangMaYong,項目名稱:android-apkbox,代碼行數:25,代碼來源:ApkManifestParser.java

示例6: parseXml

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
protected void parseXml(InputStream inputStream)
		throws XmlPullParserException, IOException
{
	mStack.clear();

	XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
	factory.setNamespaceAware(false);

	XmlPullParser parser = factory.newPullParser();
	parser.setInput(inputStream, "UTF-8");
	parser.setFeature(Xml.FEATURE_RELAXED, true);

	int eventType = parser.getEventType();
	while (eventType != XmlPullParser.END_DOCUMENT) {
		if (eventType == XmlPullParser.START_TAG) {
			mStack.push(parser.getName());
			onStartElement(new SimpleXmlPath(mStack), parser);
		} else if (eventType == XmlPullParser.END_TAG) {
			mStack.pop();
		} else if (eventType == XmlPullParser.TEXT) {
			onTextContent(new SimpleXmlPath(mStack), parser.getText());
		}

		eventType = parser.next();
	}
}
 
開發者ID:0xe1f,項目名稱:ararat,代碼行數:27,代碼來源:SimpleXmlParser.java

示例7: convertToJSONObject

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
private
@Nullable
JSONObject convertToJSONObject() {
    try {
        Tag parentTag = new Tag("", "xml");

        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(false);   // tags with namespace are taken as-is ("namespace:tagname")
        XmlPullParser xpp = factory.newPullParser();

        setInput(xpp);

        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.START_DOCUMENT) {
            eventType = xpp.next();
        }
        readTags(parentTag, xpp);

        unsetInput();

        return convertTagToJson(parentTag, false);
    } catch (XmlPullParserException | IOException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:smart-fun,項目名稱:XmlToJson,代碼行數:27,代碼來源:XmlToJson.java

示例8: parse

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
public static List<Program> parse(String in) throws XmlPullParserException, IOException {
        try {
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(true);
            XmlPullParser xpp = factory.newPullParser();
            Log.d(TAG, "Start parsing");
            Log.d(TAG, in.substring(0, 36));
            xpp.setInput(new StringReader(in));
            int eventType = xpp.getEventType();
            Log.d(TAG, eventType+"");
//            if(eventType == XmlPullParser.START_DOCUMENT)
//                xpp.next();
            /*
            xpp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
            xpp.setInput(new InputStreamReader(in));*/
            /*xpp.nextTag();
            xpp.nextTag();
            */return readFeed(xpp);
        } finally {
//            in.close();
        }
    }
 
開發者ID:Fleker,項目名稱:ChannelSurfer,代碼行數:23,代碼來源:XMLTVParser.java

示例9: readxml

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
private String readxml(String xmlstr) {
    int i = xmlstr.indexOf("<msg>");
    String xml = xmlstr.substring(i);
    String keyurl = "";
    try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser xpp = factory.newPullParser();
        xpp.setInput(new StringReader(xml));
        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                if (xpp.getName().equals("nativeurl")) {
                    xpp.nextToken();
                    keyurl = xpp.getText();
                    break;
                }
            }
            eventType = xpp.next();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return keyurl;
}
 
開發者ID:qingyan1990,項目名稱:luckymoney,代碼行數:26,代碼來源:GhostLuckyMoney.java

示例10: getXmlPullParser

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * Gets a XmlPullParser for use in parsing incoming messages.
 *
 * @return parser instance
 */
private static XmlPullParser getXmlPullParser() {
    SoftReference<XmlPullParser> ref = XPP_PARSER.get();
    XmlPullParser result = ref.get();
    if (result == null) {
        Exception thrown;
        try {
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(false);
            result = factory.newPullParser();
            ref = new SoftReference<XmlPullParser>(result);
            XPP_PARSER.set(ref);
            return result;
        } catch (Exception ex) {
            thrown = ex;
        }
        throw(new IllegalStateException(
                "Could not create XmlPull parser", thrown));
    } else {
        return result;
    }
}
 
開發者ID:CJC-ivotten,項目名稱:androidPN-client.,代碼行數:28,代碼來源:BodyParserXmlPull.java

示例11: parseXMLResponse

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * Parse is as an Invalid Path Exception
 * @param is
 * @return if The exception is an Invalid Char Exception
 * @throws XmlPullParserException
 * @throws IOException
 */
public boolean parseXMLResponse(InputStream is) throws XmlPullParserException,
           IOException {
       boolean result = false;

	try {
		// XMLPullParser
		XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
		factory.setNamespaceAware(true);

		XmlPullParser parser = Xml.newPullParser();
		parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
		parser.setInput(is, null);
		parser.nextTag();
		result = readError(parser);

	} finally {
		is.close();
	}
	return result;
}
 
開發者ID:PicFrame,項目名稱:picframe,代碼行數:28,代碼來源:InvalidCharacterExceptionParser.java

示例12: setXmlPullParser

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
public boolean setXmlPullParser(boolean mLookForXml) throws XmlPullParserException, IOException{
	if (!mLookForXml) {
		mXpp = mContext.getResources().getXml(R.xml.awesomeguy);
	}
	else {
		
	   XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
	   factory.setNamespaceAware(true);
	   mXpp = factory.newPullParser(); 	
	   File sdcard = Environment.getExternalStorageDirectory();
	   //Log.e("XML", sdcard.getAbsolutePath());
	   int BUFFER_SIZE = 8192;

	   
	   File mFileInput = new File(sdcard, SDCARD_FILE);
	   
	   FileReader mReader = new FileReader(mFileInput);
	   
	   BufferedReader in = new BufferedReader(mReader,BUFFER_SIZE);

	   mXpp.setInput(in);
		   
	}
	return true;
}
 
開發者ID:radiodee1,項目名稱:awesomeguy,代碼行數:26,代碼來源:InitBackground.java

示例13: parse

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:beansoftapp,項目名稱:react-native-console,代碼行數:43,代碼來源:GradleDependencyEntity.java

示例14: Dsmlv2ResponseParser

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * Creates a new instance of Dsmlv2ResponseParser.
 *
 * @param codec The Ldap Service to use
 * @throws XmlPullParserException if an error occurs while the initialization of the parser
 */
public Dsmlv2ResponseParser( LdapApiService codec ) throws XmlPullParserException
{
    this.container = new Dsmlv2Container( codec );

    this.container.setGrammar( Dsmlv2ResponseGrammar.getInstance() );

    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware( true );
    XmlPullParser xpp = factory.newPullParser();

    container.setParser( xpp );
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:19,代碼來源:Dsmlv2ResponseParser.java

示例15: parseXml

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
public static XmlElement parseXml(InputStream in) throws XmlPullParserException, IOException {
    if (in == null) {
        return null;
    }
    
    XmlElement result = null;
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser xpp = factory.newPullParser();
    xpp.setInput(in, HTTP.UTF_8);
    int eventType = xpp.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
        if (eventType == XmlPullParser.START_TAG) {
            result = new XmlElement(xpp.getName());
            result.parseXml(xpp);
        } else {
            try {
                if (eventType != XmlPullParser.START_DOCUMENT) {
                    LogUtils.w(XmlPullParser.TYPES[eventType]);
                }
            } catch (Throwable t) {
                LogUtils.e("Oh! My God!", t);
            }
        }
        eventType = xpp.next();
    }
    return result;
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:29,代碼來源:XmlElement.java


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