public static Map<String, String> fetchValuesFromReponse(String response) {
    Map<String, String> responseValues = new HashMap<String, String>();
    try {

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

      xpp.setInput(new StringReader(response));
      int eventType = xpp.getEventType();
      String tag = null;
      String value = null;
      while (eventType != XmlPullParser.END_DOCUMENT) {
        if (eventType == XmlPullParser.START_TAG && xpp.getName() != null) {
          tag = xpp.getName();
          eventType = xpp.next();
          value = xpp.getText();
          if (responseValues.keySet().contains(tag)) {
            value = responseValues.get(tag) + "##" + value;
          }
          responseValues.put(tag, value);
        } else {
          eventType = xpp.next();
        }
      }
    } catch (Exception anExcep) {
      anExcep.printStackTrace();
    }
    return responseValues;
  }
  @Test()
  public void testURLInvocation_schemaLocation() throws Exception {

    SimpleClient http = new SimpleClient();

    // reset the counter
    http.sendGet(_URL_ + "/reset");
    String response = http.sendGet(_URL_ + "/getCounter");
    assertEquals("0", response);

    String xmlFile = "data/data/de.rub.nds.parsers/url_invocation_schemaLocation.xml";

    String name;
    String value;
    int event;

    factory = XmlPullParserFactory.newInstance();
    parser = factory.newPullParser();
    InputStream xmlInput = new FileInputStream(xmlFile);
    parser.setInput(xmlInput, "UTF-8");

    int token = parser.nextToken();
    int i = 0;

    //          parse the entire Document
    while (token != XmlPullParser.END_DOCUMENT) {
      token = parser.nextToken();
      i++;
    }

    response = http.sendGet(_URL_ + "/getCounter");
    assertEquals("0", response);
  }
Example #3
0
    @Override
    protected Boolean doInBackground(Object... params) {
      boolean result = false;

      String pathToData = (String) params[0];
      table = (TableLayout) params[1];

      XmlPullParser data;
      try {
        Log.i("Comment", "Connecting to " + pathToData);

        URL xmlUrl = new URL(pathToData);
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        data = factory.newPullParser();
        data.setInput(xmlUrl.openStream(), null);
      } catch (XmlPullParserException e) {
        data = null;
        e.printStackTrace();
      } catch (IOException e) {
        data = null;
        e.printStackTrace();
      }

      if (data != null) {
        try {
          Log.i("Note", "Processing XML");
          processHistory(data);
        } catch (XmlPullParserException e) {
          Log.e("My Debug Tag", "Pull Parser failure", e);
        } catch (IOException e) {
          Log.e("My Debug Tag", "IO Exception parsing XML", e);
        }
      }
      return result;
    }
Example #4
0
    @Override
    protected void onPostExecute(String result) {
      try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser xpp = factory.newPullParser();
        xpp.setInput(new StringReader(result));

        ArrayList<String> routeNumbers = XmlParser.getRouteNumbers(xpp);
        xpp.setInput(new StringReader(result)); // reset parser
        ArrayList<String> routeNames = XmlParser.getRouteNames(xpp);

        ArrayList<Map<String, String>> routes = new ArrayList<Map<String, String>>();
        for (int i = 0; i < routeNames.size(); i++) {
          Map<String, String> map = new HashMap<String, String>();
          map.put("routeNumber", routeNumbers.get(i));
          map.put("routeName", routeNames.get(i));
          routes.add(map);
        }

        listView = (ListView) getView().findViewById(R.id.busListView);
        adapter = new BusStopsAdapter(routes, getActivity());
        listView.setAdapter(adapter);
        listView.setTextFilterEnabled(true);
        listView.setOnItemClickListener(BusFragment.this);

        progressDialog.dismiss();
      } catch (XmlPullParserException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
 public List<ControllerConfiguration> parse(InputStream is) throws RobotCoreException {
   this.parser = null;
   try {
     XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance();
     newInstance.setNamespaceAware(true);
     this.parser = newInstance.newPullParser();
     this.parser.setInput(is, null);
     int next = this.parser.getEventType();
     while (next != XmlPullParser.END_DOCUMENT) {
       ConfigurationType type = getConfigurationType(this.parser.getName());
       if (next == XmlPullParser.START_TAG) {
         if (type == ConfigurationType.MOTOR_CONTROLLER) {
           this.controllerConfigurations.add(parseMotorController(true));
         }
         if (type == ConfigurationType.SERVO_CONTROLLER) {
           this.controllerConfigurations.add(parseServoController(true));
         }
         if (type == ConfigurationType.LEGACY_MODULE_CONTROLLER) {
           this.controllerConfigurations.add(parseLegacyModuleController());
         }
         if (type == ConfigurationType.DEVICE_INTERFACE_MODULE) {
           this.controllerConfigurations.add(parseDeviceInterfaceModule());
         }
       }
       next = this.parser.next();
     }
   } catch (XmlPullParserException e) {
     RobotLog.w("XmlPullParserException");
     e.printStackTrace();
   } catch (IOException e2) {
     RobotLog.w("IOException");
     e2.printStackTrace();
   }
   return this.controllerConfigurations;
 }
 private void readXML() throws XmlPullParserException, IOException {
   String tagName = "";
   XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
   factory.setNamespaceAware(true);
   XmlPullParser xpp = factory.newPullParser();
   try {
     InputStream in = openFileInput("settings.xml");
     InputStreamReader isr = new InputStreamReader(in);
     BufferedReader reader = new BufferedReader(isr);
     String str;
     StringBuffer buf = new StringBuffer();
     while ((str = reader.readLine()) != null) {
       buf.append(str);
     }
     in.close();
     xpp.setInput(new StringReader(buf.toString()));
     int eventType = xpp.getEventType();
     while (eventType != XmlPullParser.END_DOCUMENT) {
       if (eventType == XmlPullParser.START_DOCUMENT) {
       } else if (eventType == XmlPullParser.END_DOCUMENT) {
       } else if (eventType == XmlPullParser.START_TAG) {
         tagName = xpp.getName();
       } else if (eventType == XmlPullParser.END_TAG) {
       } else if (eventType == XmlPullParser.TEXT) {
         if (tagName.contains("sound_setting")) {
           soundEnabled = Boolean.parseBoolean(xpp.getText().toString());
         }
       }
       eventType = xpp.next();
     }
   } catch (Exception FileNotFoundException) {
     System.out.println("File Not Found");
   }
 }
Example #7
0
  /**
   * Convert XMPPIQ to XMPPBean to simplify the handling of the IQ using the beanPrototypes.
   *
   * @param iq the XMPPIQ
   * @return the related XMPPBean or null if something goes wrong
   */
  public XMPPBean convertXMPPIQToBean(XMPPIQ iq) {

    try {
      String childElement = iq.element;
      String namespace = iq.namespace;
      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
      XmlPullParser parser = factory.newPullParser();
      parser.setInput(new StringReader(iq.payload));
      XMPPBean bean = null;

      Log.v(
          TAG,
          "prototypes contains ns: "
              + namespace
              + "? "
              + this.beanPrototypes.containsKey(namespace));
      if (this.beanPrototypes.containsKey(namespace))
        Log.v(
            TAG,
            "prototypes contains ce: "
                + childElement
                + "? "
                + this.beanPrototypes.get(namespace).containsKey(childElement));

      synchronized (this.beanPrototypes) {
        if (namespace != null
            && this.beanPrototypes.containsKey(namespace)
            && this.beanPrototypes.get(namespace).containsKey(childElement)) {

          bean = (this.beanPrototypes.get(namespace).get(childElement)).clone();
          bean.fromXML(parser);

          bean.setId(iq.packetID);
          bean.setFrom(iq.from);
          bean.setTo(iq.to);

          switch (iq.type) {
            case XMPPIQ.TYPE_GET:
              bean.setType(XMPPBean.TYPE_GET);
              break;
            case XMPPIQ.TYPE_SET:
              bean.setType(XMPPBean.TYPE_SET);
              break;
            case XMPPIQ.TYPE_RESULT:
              bean.setType(XMPPBean.TYPE_RESULT);
              break;
            case XMPPIQ.TYPE_ERROR:
              bean.setType(XMPPBean.TYPE_ERROR);
              break;
          }

          return bean;
        }
      }
    } catch (Exception e) {
      Log.e(TAG, "ERROR while parsing XMPPIQ to XMPPBean: " + e.getMessage());
    }

    return null;
  }
Example #8
0
  public static void main(String args[]) throws XmlPullParserException, IOException {

    XmlPullParserFactory factory =
        XmlPullParserFactory.newInstance(
            System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
    factory.setNamespaceAware(false);
    System.err.println("using factory " + factory.getClass());

    XmlPullParser xpp = factory.newPullParser();
    System.err.println("using parser " + xpp.getClass());

    XmlPullCount app = new XmlPullCount();

    app.verbose = true;
    for (int c = 0; c < 2; ++c) {
      System.err.println("run#" + c);
      app.resetCounters();
      if (args.length == 0) {
        System.err.println("Parsing simple sample XML length=" + SAMPLE_XML.length());
        xpp.setInput(new StringReader(SAMPLE_XML));
        app.countXml(xpp);
      } else {
        // r (int i = 0; i < args.length; i++) {

        File f = new File(args[0]);
        System.err.println("Parsing file: " + args[0] + " length=" + f.length());
        // xpp.setInput ( new FileReader ( args [0] ) );
        xpp.setInput(new FileInputStream(args[0]), "UTF8");
        app.countXml(xpp);
        //
      }
      app.printReport();
    }
    System.err.println("finished");
  }
  @Test
  public void testStandard() throws FileNotFoundException, XmlPullParserException, IOException {

    String xmlFile = "data/data/de.rub.nds.parsers/standard.xml";
    String name;
    String value;
    int event;

    factory = XmlPullParserFactory.newInstance();
    parser = factory.newPullParser();
    InputStream xmlInput = new FileInputStream(xmlFile);
    parser.setInput(xmlInput, "UTF-8");

    //        parser.nextToken(); // element
    parser.nextTag();
    name = parser.getName();
    value = parser.getText(); // not used here
    event = parser.getEventType();
    assertEquals("data", name);
    assertEquals(2, event);

    parser.nextToken(); // the content of the element

    // make sure to override ALL values; otherwise we produce assertion errors!
    name = parser.getName();
    value = parser.getText();
    event = parser.getEventType();
    assertEquals(4, event);
    assertEquals("4", value);
  }
  /**
   * @throws FileNotFoundException
   * @throws XmlPullParserException
   * @throws XmlPullParserException: This parser doesn't support parameter entities
   *     (position:DOCDECL @4:15 in java.io.InputStreamReader@ec20ff4)
   */
  @Test(expected = XmlPullParserException.class)
  public void testDOS_indirections_parameterEntity_FEATURE_PROCESS_DOCDECL()
      throws FileNotFoundException, XmlPullParserException, IOException {

    String xmlFile = "data/data/de.rub.nds.parsers/dos_indirections_parameterEntity.xml";

    String name;
    String value;
    int event;

    factory = XmlPullParserFactory.newInstance();
    factory.setFeature(XmlPullParser.FEATURE_PROCESS_DOCDECL, true);
    parser = factory.newPullParser();

    InputStream xmlInput = new FileInputStream(xmlFile);
    parser.setInput(xmlInput, "UTF-8");

    int token = parser.nextToken();
    name = parser.getName();
    value = parser.getText();
    event = parser.getEventType();
    assertEquals(10, event);

    parser.nextToken(); // IGNORABLE_WHITESPACE - this call is necessary in order to trigger the
    // exception.
    name = parser.getName();
    value = parser.getText();
    event = parser.getEventType();
    assertEquals(7, event);
  }
  @Test
  public void testXInclude() throws FileNotFoundException, XmlPullParserException, IOException {

    String xmlFile = "data/data/de.rub.nds.parsers/xinclude.xml";

    String name;
    String value;
    int event;

    factory = XmlPullParserFactory.newInstance();
    parser = factory.newPullParser();
    InputStream xmlInput = new FileInputStream(xmlFile);
    parser.setInput(xmlInput, "UTF-8");

    parser.nextToken(); // element
    name = parser.getName();
    value = parser.getText(); // not used here
    event = parser.getEventType();
    assertEquals("data", name);
    assertEquals(2, event);

    parser.nextToken();
    name = parser.getName();
    value = parser.getText();
    event = parser.getEventType();
    assertEquals(2, event);
    assertEquals(null, value);
    assertEquals("xi:include", name);
  }
 private static XmlPullParser buildParser(CharSequence contents) throws XmlPullParserException {
   XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
   factory.setNamespaceAware(true);
   XmlPullParser xpp = factory.newPullParser();
   xpp.setInput(new StringReader(contents.toString()));
   return xpp;
 }
  @Override
  protected List<LineStatus> doInBackground(String[]... params) {
    try {
      URL url = new URL(this.url);
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.setReadTimeout(10000 /* milliseconds */);
      connection.setConnectTimeout(15000 /* milliseconds */);
      connection.setRequestMethod("GET");
      connection.setDoInput(true);
      connection.connect();
      InputStream stream = connection.getInputStream();

      xmlFactoryObject = XmlPullParserFactory.newInstance();
      XmlPullParser xpp = xmlFactoryObject.newPullParser();

      xpp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
      xpp.setInput(stream, null);

      // Parsing code
      List<LineStatus> result = parseXML(xpp);
      stream.close();

      return result;

    } catch (Exception e) {
      e.printStackTrace();
      Log.e("AsyncTask", "exception");
      return null;
    }
  }
  // -----------------------------------------------------------------------------------
  private static String getXMLMessage(String msg)
      throws JSONException, XmlPullParserException, IOException {

    String xmlMessage = null;
    InputStream is = new ByteArrayInputStream(msg.getBytes());
    // Using Pull Parser
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser xmlPullParser = factory.newPullParser();
    xmlPullParser.setInput(is, "UTF-8");

    // --------------------------------------------------------
    // Start Parsing XML Data
    // --------------------------------------------------------
    while (xmlPullParser.next() != XmlPullParser.END_DOCUMENT) {

      if (xmlPullParser.getEventType() == XmlPullParser.START_TAG) {
        if (xmlPullParser.getName().equals("string")) {
          xmlPullParser.next();
          xmlMessage = xmlPullParser.getText();
          break;
        }
      }
    }

    return xmlMessage;
  }
Example #15
0
  /*
   * Parse 'content'
   *
   * Logs used to debug
   */
  public String parseThumbLink(String str) throws XmlPullParserException, IOException {
    String src = null;

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

    xpp.setInput(new StringReader(str));
    int eventType = xpp.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
      if (eventType == XmlPullParser.START_DOCUMENT) {
        // Log.d(logtag, "Start document");
      } else if (eventType == XmlPullParser.START_TAG) {
        // Log.d(logtag, "Start tag " + xpp.getName());
        if (xpp.getName().equals("img")) {
          src = xpp.getAttributeValue(null, "src");
          Log.d(logtag, "src: " + xpp.getAttributeValue(null, "src"));
        }
      } else if (eventType == XmlPullParser.END_TAG) {
        // Log.d(logtag, "End tag " + xpp.getName());
      } else if (eventType == XmlPullParser.TEXT) {
        // Log.d(logtag, "Text " + xpp.getText());
      }
      eventType = xpp.next();
    }

    return src;
  }
Example #16
0
  public static ArrayList<NewsData> getDataFromUrl(String urlString) {
    try {
      // configurating connection
      URL url = new URL(urlString);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();

      conn.setReadTimeout(10000 /* milliseconds */);
      conn.setConnectTimeout(15000 /* milliseconds */);
      conn.setRequestMethod("GET");
      conn.setDoInput(true);

      // Starts the query
      conn.connect();
      InputStream stream = conn.getInputStream();

      XmlPullParserFactory xmlFactoryObject = XmlPullParserFactory.newInstance();
      XmlPullParser parser = xmlFactoryObject.newPullParser();

      parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
      parser.setInput(stream, null);

      // parsing data from response
      ArrayList<NewsData> newsDatas = parseNewsData(parser);

      stream.close();

      return newsDatas;
    } catch (Exception e) {
      return null;
    }
  }
Example #17
0
  public List<Bird> parseXML(Context context) {

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

      InputStream stream = context.getResources().openRawResource(com.example.birdnote.R.raw.birds);
      xpp.setInput(stream, null);

      int eventType = xpp.getEventType();
      while (eventType != XmlPullParser.END_DOCUMENT) {
        if (eventType == XmlPullParser.START_TAG) {
          handleStartTag(xpp.getName());
        } else if (eventType == XmlPullParser.END_TAG) {
          currentTag = null;
        } else if (eventType == XmlPullParser.TEXT) {
          handleText(xpp.getText());
        }
        eventType = xpp.next();
      }

    } catch (NotFoundException e) {
      Log.d(LOGTAG, e.getMessage());
    } catch (XmlPullParserException e) {
      Log.d(LOGTAG, e.getMessage());
    } catch (IOException e) {
      Log.d(LOGTAG, e.getMessage());
    }

    return birds;
  }
  private void writeDataElements(Writer out, HashTree sorted) throws IOException {
    XmlSerializer xml = null;
    try {
      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
      xml = factory.newSerializer();
    } catch (XmlPullParserException xppe) {
      throw new RuntimeException("Couldn't obtain xml serializer", xppe);
    }

    // we need to write our header manually, because we need to specify
    // XML version 1.1
    out.write(DATA_XML_HEADER + NEWLINE + NEWLINE);

    xml.setOutput(out);
    xml.startTag(null, DATA_ELEM);
    xml.ignorableWhitespace(NEWLINE);

    writeDataElementsForNode(xml, sorted, 0);

    xml.endTag(null, DATA_ELEM);
    xml.ignorableWhitespace(NEWLINE);
    xml.endDocument();

    out.flush();
  }
Example #19
0
  public static String getMediaUrl(String response) throws XmlPullParserException, IOException {

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

    String result = null;

    parser.setInput(new StringReader(response));
    int eventType = parser.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
      String name = null;
      switch (eventType) {
        case XmlPullParser.START_DOCUMENT:
          break;
        case XmlPullParser.START_TAG:
          name = parser.getName();
          if (name.equalsIgnoreCase("mediaurl")) {
            result = parser.nextText();
          }
          break;
        case XmlPullParser.END_TAG:
          break;
      }
      eventType = parser.next();
    }

    return result;
  }
  public List<Employee> parse(InputStream inputStream) {
    XmlPullParserFactory factory = null;
    XmlPullParser parser = null;

    try {
      factory = XmlPullParserFactory.newInstance();
      factory.setNamespaceAware(true);
      parser = factory.newPullParser();

      parser.setInput(inputStream, null);

      int eventType = parser.getEventType();

      while (eventType != XmlPullParser.END_DOCUMENT) {
        String tagname = parser.getName();

        switch (eventType) {
          case XmlPullParser.START_TAG:
            if (tagname.equalsIgnoreCase("employee")) {
              // create a new instance of employess
              employee = new Employee();
            }
            break;

          case XmlPullParser.TEXT:
            text = parser.getText();
            break;

          case XmlPullParser.END_TAG:
            if (tagname.equalsIgnoreCase("employee")) {
              // add employee object to list
              employees.add(employee);
            } else if (tagname.equalsIgnoreCase("name")) {
              employee.setName(text);
            } else if (tagname.equalsIgnoreCase("id")) {
              employee.setId(Integer.parseInt(text));
            } else if (tagname.equalsIgnoreCase("department")) {
              employee.setDepartment(text);
            } else if (tagname.equalsIgnoreCase("email")) {
              employee.setEmail(text);
            } else if (tagname.equalsIgnoreCase("type")) {
              employee.setType(text);
            }
            break;

          default:
            break;
        }

        eventType = parser.next();
      }
    } catch (XmlPullParserException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    return employees;
  }
 static {
   try {
     sXmlPullParserFactory = XmlPullParserFactory.newInstance();
     sXmlPullParserFactory.setNamespaceAware(true);
   } catch (XmlPullParserException e) {
     LOGE(YahooPlacesAPIClient.TAG, "Could not instantiate XmlPullParserFactory", e);
   }
 }
 /**
  * Allocate and initial an XmlPullParser
  *
  * <p>At the time this code was written the XmlPullParser did not support validation, so the call
  * to setValidating() is passed "false".
  */
 private XmlPullParser getParser() throws XmlPullParserException {
   XmlPullParserFactory factory;
   factory = XmlPullParserFactory.newInstance();
   factory.setNamespaceAware(true);
   factory.setValidating(false);
   XmlPullParser parser = factory.newPullParser();
   return parser;
 } // getParser
Example #23
0
  public MimeTypes fromXml(InputStream in) throws XmlPullParserException, IOException {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();

    mXpp = factory.newPullParser();
    mXpp.setInput(new InputStreamReader(in));

    return parse();
  }
 static {
   try {
     factory = XmlPullParserFactory.newInstance(MXParser.class.getName(), null);
     factory.setNamespaceAware(true);
   } catch (XmlPullParserException e) {
     log.error("Error creating a parser factory", e);
   }
 }
  public XmlPullParserFactory getXPPFactory() throws XmlPullParserException {
    if (xppFactory == null) {
      xppFactory = XmlPullParserFactory.newInstance();
    }

    xppFactory.setNamespaceAware(true);

    return xppFactory;
  }
 static {
   try {
     PARSER_FACTORY = XmlPullParserFactory.newInstance();
     PARSER_FACTORY.setNamespaceAware(true);
     PARSER_FACTORY.setValidating(false);
   } catch (XmlPullParserException e) {
     log.severe(e.toString());
   }
 }
  protected XmlPullParser buildXmlParser(String xml) throws XmlPullParserException {
    XmlPullParser xpp = null;

    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    xpp = factory.newPullParser();
    xpp.setInput(new StringReader(xml));

    return xpp;
  }
  public boolean process() {
    boolean status = true;
    Application currentRecord = null;
    boolean inEntry = false;
    String textValue = "";

    try {
      XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
      factory.setNamespaceAware(true);
      XmlPullParser xpp = factory.newPullParser();
      xpp.setInput(new StringReader(this.xmlData));
      int eventType = xpp.getEventType();

      while (eventType != XmlPullParser.END_DOCUMENT) {
        String tagName = xpp.getName();
        switch (eventType) {
          case XmlPullParser.START_TAG:
            // Log.d("ParseApplications", "Starting tag for " + tagName);
            if (tagName.equalsIgnoreCase("entry")) {
              inEntry = true;
              currentRecord = new Application();
            }
            break;

          case XmlPullParser.TEXT:
            textValue = xpp.getText();
            break;

          case XmlPullParser.END_TAG:
            // Log.d("ParseApplications", "Ending tag for " + tagName);
            if (inEntry) {
              if (tagName.equalsIgnoreCase("entry")) {
                applications.add(currentRecord);
                inEntry = false;
              } else if (tagName.equalsIgnoreCase("name")) {
                currentRecord.setName(textValue);
              } else if (tagName.equalsIgnoreCase("artist")) {
                currentRecord.setArtist(textValue);
              } else if (tagName.equalsIgnoreCase("releaseDate")) {
                currentRecord.setReleaseDate(textValue);
              }
            }
            break;

          default:
            // nothing else to do
        }
        eventType = xpp.next();
      }

    } catch (Exception e) {
      status = false;
      e.printStackTrace();
    }
    return true;
  }
Example #29
0
  private static XmlPullParser CreatePullParser(InputStream readerStream)
      throws XmlPullParserException {
    XmlPullParserFactory xppf = XmlPullParserFactory.newInstance();
    xppf.setNamespaceAware(false);

    XmlPullParser xpp = xppf.newPullParser();
    xpp.setInput(readerStream, null);

    return xpp;
  }
Example #30
0
 private static synchronized XmlPullParserFactory getParserFactory()
     throws XmlPullParserException {
   if (factory == null) {
     factory =
         XmlPullParserFactory.newInstance(
             System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
     factory.setNamespaceAware(true);
   }
   return factory;
 }