1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
   |  
  private void testParse(String xmlString)
  {
    // create factory
    SAXParserFactory factory = SAXParserFactory.newInstance();
    DefaultHandler handler =    new DefaultHandler();
 
    // set it so that it is validating and namespace aware
    factory.setValidating( true );
    factory.setNamespaceAware( true );
    try
    {
      SAXParser parser = factory.newSAXParser();
      parser.parse( new InputSource(new StringReader(xmlSamples)), handler );
      System.out.println();
    }
    catch(IOException e)
    {
      e.printStackTrace();
    }
    catch( SAXException e )
    {
      e.printStackTrace();
    }
    catch( ParserConfigurationException e )
    {
      e.printStackTrace();
    }
 
  } | 
Partager