SAX parsing - efficient way to get text nodes

后端 未结 2 1774
轮回少年
轮回少年 2020-12-30 11:35

Given this XML snippet



   
      Gambardella, Matthew


        
相关标签:
2条回答
  • 2020-12-30 12:14
    public void startElement(String strNamespaceURI, String strLocalName,
          String strQName, Attributes al) throws SAXException {
           if(strLocalName.equalsIgnoreCase("HIT"))
           {
                String output1 = al.getValue("NAME");
              //this will work but how can we parse if NAME="abc" only     ?
           }
    
       }
    
    0 讨论(0)
  • 2020-12-30 12:41

    That's the usual way to do it with SAX.

    Just beware that characters() may be called more than once per tag. See this question for more info. Here is a complete example.

    Otherwise you could give a try to StAX.

    0 讨论(0)
提交回复
热议问题