有哪些库可用于在Google App Engine / Java Servlet上处理XML

我正在Eclipse中编写Java servlet(将在Google App Engine上托管),并且需要处理XML文档.有哪些易于添加到Eclipse项目中并具有良好示例代码的库?

解决方法:

我最终将JAXP与SAX API结合使用.

在我的servlet中添加以下内容

import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.parsers.*;

....

InputStream in = connection.getInputStream();

InputSource responseXML = new InputSource(in);
final StringBuilder response = new StringBuilder();
DefaultHandler myHandler = new DefaultHandler() {

    public void startElement(String uri, String localName, String qName, 
            Attributes attributes) throws SAXException {
        if (localName.equals("elementname")) {
            response.append(attributes.getValue("attributename"));
            inElement = true;
        }
    }
    public void characters(char [] buf, int offset, int len) {
        if (inElement) {
            inElement = false;
            String s = new String(buf, offset, len);
            response.append(s);
            response.append("\n");
        }
    }
};

SAXParserFactory factory = SAXParserFactory.newInstance();
try {
    SAXParser parser = factory.newSAXParser();
    parser.parse(responseXML, myHandler);
} catch (ParserConfigurationException e) {
    // Todo Auto-generated catch block
    e.printstacktrace();
} catch (SAXException e) {
    // Todo Auto-generated catch block
    e.printstacktrace();
}

in.close();
connection.disconnect();

....

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念