解析android saxparsing中的问题

时间:2011-09-30 05:45:30

标签: java android

@Override
public void characters(char ch[], int start, int length)
        throws SAXException {
    super.characters(ch, start, length);
    String strCharacters = new String(ch,start,length);
    if (itemFound==true){
        // "item" tag found, it's item's parameter
        switch(currentState){
            case state_title:     
                item.setTitle(strCharacters);
                break;
            case state_description:
                item.setDescription(strCharacters);
                break;  
            case state_link:
                item.setLink(strCharacters);
                break;  
            case state_pubdate:
                item.setPubdate(strCharacters);
                break;  
            default:
            break;    
        }    
    } else {
        // not "item" tag found, it's feed's parameter
        switch(currentState){
            case state_title:
            feed.setTitle(strCharacters);
            break;
            case state_description:
            feed.setDescription(strCharacters);
            break;
        case state_link:
            feed.setLink(strCharacters);
            break;
        case state_pubdate:
            feed.setPubdate(strCharacters);
            break;  
        default:
            break;
        }
    }
    currentState = state_unknown;
 }

请告诉我如何解析(&)我无法解析&在这

1 个答案:

答案 0 :(得分:0)

试试吧..它会帮助你。

private StringBuffer curTag = new StringBuffer();     public void endElement(String namespaceURI,String localName,String qName)抛出SAXException {

        if(localName.equalsIgnoreCase("Test_tag")){ 
            System.out.println(curTag.toString());
        }
}
public void characters(char ch[], int start, int length) {
        curTag.append(CharBuffer.wrap(ch, start, length));
    }