use of org.kxml2.io.KXmlParser in project ETSMobile-Android2 by ApplETS.
the class ExtendedSoapSerializationEnvelope method GetSoapObject.
public SoapObject GetSoapObject(Element detailElement) {
try {
XmlSerializer xmlSerializer = XmlPullParserFactory.newInstance().newSerializer();
StringWriter writer = new StringWriter();
xmlSerializer.setOutput(writer);
detailElement.write(xmlSerializer);
xmlSerializer.flush();
XmlPullParser xpp = new KXmlParser();
xpp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
xpp.setInput(new StringReader(writer.toString()));
xpp.nextTag();
SoapObject soapObj = new SoapObject(detailElement.getNamespace(), detailElement.getName());
readSerializable(xpp, soapObj);
return soapObj;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
use of org.kxml2.io.KXmlParser in project collect by opendatakit.
the class OpenRosaXmlFetcher method getXML.
/**
* Gets an XML document for a given url
*
* @param urlString - url of the XML document
* @return DocumentFetchResult - an object that contains the results of the "get" operation
*/
@SuppressWarnings("PMD.AvoidRethrowingException")
public DocumentFetchResult getXML(String urlString) throws Exception {
// parse response
Document doc;
HttpGetResult inputStreamResult;
try {
inputStreamResult = fetch(urlString, HTTP_CONTENT_TYPE_TEXT_XML);
if (inputStreamResult.getStatusCode() != HttpURLConnection.HTTP_OK) {
String error = "getXML failed while accessing " + urlString + " with status code: " + inputStreamResult.getStatusCode();
Timber.e(error);
return new DocumentFetchResult(error, inputStreamResult.getStatusCode());
}
try (InputStream resultInputStream = inputStreamResult.getInputStream();
InputStreamReader streamReader = new InputStreamReader(resultInputStream, "UTF-8")) {
doc = new Document();
KXmlParser parser = new KXmlParser();
parser.setInput(streamReader);
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
doc.parse(parser);
}
} catch (Exception e) {
throw e;
}
return new DocumentFetchResult(doc, inputStreamResult.isOpenRosaResponse(), inputStreamResult.getHash());
}
use of org.kxml2.io.KXmlParser in project OsmAnd-tools by osmandapp.
the class OsmAndServerMonitorTasks method countMapsInMapIndex.
private int countMapsInMapIndex(InputStream is) throws IOException, XmlPullParserException {
int mapCounter = 0;
XmlPullParser xpp = new KXmlParser();
xpp.setInput(new InputStreamReader(is));
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (xpp.getAttributeValue(0).equals("map")) {
mapCounter++;
}
}
if (eventType == XmlPullParser.TEXT) {
if (!xpp.isWhitespace()) {
throw new XmlPullParserException("Text in document");
}
}
eventType = xpp.next();
}
return mapCounter;
}
Aggregations