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;
  }
 static {
   try {
     XML_SERIALIZER_FACTORY = XmlPullParserFactory.newInstance();
   } catch (Exception e) {
     LOG.log(Level.SEVERE, "An error occurred while creating pull parser factory.", e);
   }
 }
示例#3
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;
  }
示例#4
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");
  }
  /**
   * @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 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);
  }
  @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);
  }
  @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);
  }
 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;
    }
  }
 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 boolean loadQuestionBatch(int startNumber, String pathToQuestions) throws Exception {
      boolean result = false;
      mQuestions.clear();
      int eventType = -1;

      XmlPullParser game = null;
      URL xmlUrl = new URL(pathToQuestions);
      game = XmlPullParserFactory.newInstance().newPullParser();
      game.setInput(xmlUrl.openStream(), null);

      while (eventType != XmlResourceParser.END_DOCUMENT) {
        if (eventType == XmlResourceParser.START_TAG) {
          String name = game.getName();
          if (name.equals(XML_TAG_QUESTION)) {
            String strNumber = game.getAttributeValue(null, XML_TAG_QUESTION_ATTRIBUTE_NUMBER);
            Integer number = new Integer(strNumber);
            String text = game.getAttributeValue(null, XML_TAG_QUESTION_ATTRIBUTE_TEXT);
            String imageUrl = game.getAttributeValue(null, XML_TAG_QUESTION_ATTRIBUTE_IMAGEURL);
            Question question = new Question(number, text, imageUrl);
            mQuestions.put(number, question);
          }
        }
        eventType = game.next();
        result = true;
      }
      return result;
    }
 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");
   }
 }
示例#14
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();
      }
    }
示例#15
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;
  }
示例#16
0
 private static String parseXMLError(String error) {
   // TODO Auto-generated method stub
   String result = error;
   XmlPullParser pull;
   String tag = null;
   try {
     pull = XmlPullParserFactory.newInstance().newPullParser();
     pull.setInput(new StringReader(error));
     boolean found = false;
     while (!found) {
       int type = pull.getEventType();
       switch (type) {
         case XmlPullParser.START_TAG:
           tag = pull.getName();
           if (tag.equalsIgnoreCase("error")) {
             result = pull.nextText();
           }
           break;
         case XmlPullParser.END_TAG:
           if (tag.equalsIgnoreCase("error")) {
             found = true;
           }
           break;
         default:
           break;
       }
       pull.next();
     }
   } catch (Exception e) {
   }
   return result;
 }
示例#17
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;
    }
示例#18
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;
  }
示例#19
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;
  }
示例#20
0
  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();
  }
示例#21
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;
    }
  }
  // -----------------------------------------------------------------------------------
  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;
  }
  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);
   }
 }
示例#25
0
  public MimeTypes fromXml(InputStream in) throws XmlPullParserException, IOException {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();

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

    return parse();
  }
示例#26
0
 /**
  * @param strictParsing If true, {@link #parse(InputStream)} will throw a {@link ParserException}
  *     if the stream contains invalid data. If false, the parser will make a best effort to ignore
  *     minor errors in the stream. Note however that a {@link ParserException} will still be
  *     thrown when this is not possible.
  */
 public TtmlParser(boolean strictParsing) {
   this.strictParsing = strictParsing;
   try {
     xmlParserFactory = XmlPullParserFactory.newInstance();
   } catch (XmlPullParserException e) {
     throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e);
   }
 }
示例#27
0
 /**
  * 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
示例#28
0
 static {
   try {
     factory = XmlPullParserFactory.newInstance(MXParser.class.getName(), null);
     factory.setNamespaceAware(true);
   } catch (XmlPullParserException e) {
     log.error("Error creating a parser factory", e);
   }
 }
示例#29
0
  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());
   }
 }