当前位置: 首页>>代码示例>>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;未经允许,请勿转载。