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