当前位置: 首页>>代码示例>>Java>>正文


Java XmlPullParserFactory类代码示例

本文整理汇总了Java中org.xmlpull.v1.XmlPullParserFactory的典型用法代码示例。如果您正苦于以下问题:Java XmlPullParserFactory类的具体用法?Java XmlPullParserFactory怎么用?Java XmlPullParserFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlPullParserFactory类属于org.xmlpull.v1包,在下文中一共展示了XmlPullParserFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: xmlPullParserFromSocket

import org.xmlpull.v1.XmlPullParserFactory; //导入依赖的package包/类
XmlPullParser xmlPullParserFromSocket(InputStream socketInputStream) throws IOException, XmlPullParserException {

	String line;
	StringBuilder xmlRpcText = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(socketInputStream));
	while ((line = br.readLine()) != null && line.length() > 0); // eat the HTTP POST headers
	while (br.ready())
		xmlRpcText.append(br.readLine());
	// Log.d(Tag.LOG, "xml received:" + xmlRpcText.toString());
	
	InputStream inputStream = new ByteArrayInputStream(xmlRpcText.toString().getBytes("UTF-8"));
	XmlPullParser pullParser = XmlPullParserFactory.newInstance().newPullParser();
	Reader streamReader = new InputStreamReader(inputStream);
	pullParser.setInput(streamReader);
	return pullParser;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:17,代码来源:XMLRPCServer.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: getItemContent

import org.xmlpull.v1.XmlPullParserFactory; //导入依赖的package包/类
public boolean getItemContent(final int itemId, final XulHttpServer.XulHttpServerRequest request, final XulHttpServer.XulHttpServerResponse response) {
	return execUiOpAndWait(itemId, new UiOpRunnable() {
		@Override
		boolean beginExec() {
			return !(_xulPage == null && _xulView == null);
		}

		@Override
		protected void exec(PageInfo pageInfo, XulPage xulPage, XulView xulView) throws Exception {
			if (xulView == null) {
				xulView = xulPage.getLayout();
			}

			XmlPullParserFactory xmlPullParserFactory = XmlPullParserFactory.newInstance();
			XmlSerializer writer = xmlPullParserFactory.newSerializer();
			writer.setOutput(response.getBodyStream(), "utf-8");

			writer.startDocument("utf-8", Boolean.TRUE);
			dumpItem(xulView, writer, request.queries);

			writer.endDocument();
			writer.flush();
		}
	});
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:26,代码来源:XulDebugMonitor.java

示例8: 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

示例9: fromFile

import org.xmlpull.v1.XmlPullParserFactory; //导入依赖的package包/类
public static Resources fromFile(final File file) {
    Resources result = new Resources(file);

    if (file.isFile()) {
        InputStream is = null;
        try {
            is = new FileInputStream(file);
            // Load the resources from the XML into our resulting Resources
            final XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
            ResourcesParser.loadFromXml(is, result, parser);
        } catch (IOException | XmlPullParserException e) {
            e.printStackTrace();
        } finally {
            try {
                if (is != null)
                    is.close();
            } catch (IOException ignored) {
            }
        }
    }

    // If loading went okay, the resources will have been loaded into the result
    return result;
}
 
开发者ID:LonamiWebs,项目名称:Stringlate,代码行数:25,代码来源:Resources.java

示例10: save

import org.xmlpull.v1.XmlPullParserFactory; //导入依赖的package包/类
public boolean save() {
    if (mSavedChanges)
        return true;

    if (mFile == null)
        return false;

    try {
        if (!mFile.getParentFile().isDirectory())
            mFile.getParentFile().mkdirs();

        FileOutputStream out = new FileOutputStream(mFile);
        final XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer();
        mSavedChanges = ResourcesParser.parseToXml(this, out, serializer);
        mModified = true;
        out.close();
    } catch (IOException | XmlPullParserException e) {
        e.printStackTrace();
    }
    // We do not want empty files, if it exists and it's empty delete it
    if (mFile.isFile() && mFile.length() == 0)
        mFile.delete();

    return mFile.isFile();
}
 
开发者ID:LonamiWebs,项目名称:Stringlate,代码行数:26,代码来源:Resources.java

示例11: 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

示例12: AsyncKmlParser

import org.xmlpull.v1.XmlPullParserFactory; //导入依赖的package包/类
public AsyncKmlParser(Activity activity, GoogleMaps mapCtrl, String kmlId, CallbackContext callbackContext, Bundle option) {
  this.kmlId = kmlId;
  mCallback = callbackContext;
  mMapCtrl = mapCtrl;
  mActivity = activity;
  mOption = option;
  if (option.containsKey("preserveViewport")) {
    preserveViewport = option.getBoolean("preserveViewport");
  }
  if (option.containsKey("animation")) {
    animation = option.getBoolean("animation");
  }

  mProgress = ProgressDialog.show(activity, "", "Please wait...", false);
  start = System.currentTimeMillis();
  
  try {
    parser = XmlPullParserFactory.newInstance().newPullParser();
  } catch (Exception e) {
    e.printStackTrace();
    callbackContext.error(e.toString());
  }
}
 
开发者ID:AdrianBZG,项目名称:PhoneChat,代码行数:24,代码来源:AsyncKmlParser.java

示例13: write

import org.xmlpull.v1.XmlPullParserFactory; //导入依赖的package包/类
@Override
public final void write(OutputStream out) throws IOException
{
	try
	{
		xml = XmlPullParserFactory.newInstance().newSerializer();
	}
	catch(XmlPullParserException e)
	{
		throw new RuntimeException("Cannot initialize serializer", e);
	}
	xml.setOutput(out, CHARSET);
	xml.startDocument(CHARSET, null);

	write();

	if(xml.getName() != null)
	{
		throw new IllegalStateException("Forgot to close a tag");
	}

	xml.endDocument();
	xml.flush();
}
 
开发者ID:westnordost,项目名称:osmapi,代码行数:25,代码来源:XmlWriter.java

示例14: doLoadLocalMap

import org.xmlpull.v1.XmlPullParserFactory; //导入依赖的package包/类
void doLoadLocalMap(final String path) {
	new Thread(){

		@Override
		public void run() {
			try {
				XmlPullParserFactory factory = XmlPullParserFactory.newInstance();

				XmlPullParser xpp = factory.newPullParser();
				xpp.setInput(new InputStreamReader(new FileInputStream(new File(path)), "UTF-8"));
				xpp.next();


				ObjectsLocalActivity.domainEntity = (DomainEntity) DomainUtils.recursiveEntityReading(xpp);
				ObjectsLocalActivity.domainLocalPath = path;
				postConnInfo("Domain entity successfully loaded");
			} catch (XmlPullParserException | IOException e) {
				postConnInfo("" + e);
			}
		}

	}.start();
}
 
开发者ID:nmud,项目名称:nmud,代码行数:24,代码来源:MainActivity.java

示例15: parseIndex

import org.xmlpull.v1.XmlPullParserFactory; //导入依赖的package包/类
public static ArrayList<ConferenceMeta> parseIndex() throws XmlPullParserException, IOException {

        conferences = new ArrayList<>();

        pullParserFactory = XmlPullParserFactory.newInstance();
        XmlPullParser parser = pullParserFactory.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);

        Log.d("Parse", "parse");
        URL url = new URL(INDEX_FILE_URL);
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        InputStream inputStream = null;

        try {
            inputStream = new BufferedInputStream(urlConnection.getInputStream());
            parser.setInput(inputStream, null);
            readIndex(parser);
        } finally {
            urlConnection.disconnect();
            inputStream.close();
        }

        return conferences;
    }
 
开发者ID:BuildmLearn,项目名称:mConference-Framework,代码行数:25,代码来源:IndexParser.java


注:本文中的org.xmlpull.v1.XmlPullParserFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。