哪跟哪啊
整个一关公战秦琼建议驱看看SAX和DOM的基础知识先

解决方案 »

  1.   

    不要用这样口气跟我讲,我也不是一点不懂。SAX基于事件流嘛,顺序读入内存,逐步操作
    DOM先把整个树状结构读入内存,可以随机操作我只是想知道能不能把DOM树作为输入,
    用SAX的操作方式做处理,因为我这里获得的是一个
    客户端传过来的DOM,而想做的处理用DOM操作
    略嫌复杂。
    /               \           /              \
    |                \         /                |
    |            ︵   \       /   ︵            |
    \︶\︶\︶|︶|  \   \     /   /  |︶|︶/︶/︶/
     \  \  \ |  |    ︶       ︶    |  | /  /  /
      ︶ ︶╰|  |                   |  |╯︶ ︶
             |︶|                   |︶|
             |  |     !!!!!    |  |
              ︶                     ︶
      

  2.   

    把dom转换成流作为SAX的输入,根据xml中相关属性值和其他值
    拼装特殊语句(如sql)
    不过我现在用dom也已经实现了
      

  3.   

    根据xml中相关属性值和其他值
    拼装特殊语句(如sql)
    ----------------------用DOM实现不了吗?还要倒退回去干吗呢
      

  4.   

    可是用sax调试的过程清楚
    dom用的递归,一不小心就乱了
      

  5.   

    呵呵为什么要递归xpath是最好的选择
      

  6.   

    大家不要互相鄙视了。你可以试试将DOM对象输入到一个STREAM(用DOCUMENT对象根NODE的TOSRING方法,再用SAX来读者个STREAM。
      

  7.   

    Plays well with others: Interoperating with existing XML tools
    One of the interesting features of JDOM is its interoperability with other APIs. Using JDOM, you can output a document not only to a Stream or a Reader, but also as a SAX Event Stream or as a DOM Document. This flexibility allows JDOM to be used in a heterogeneous environment or to be added to systems already using another method for handling XML. As we'll see in a later example, it also allows JDOM to use other XML tools that don't yet recognize the JDOM data structures natively. Another use of JDOM is the ability to read and manipulate XML data that already exists. Reading a well-formed XML file is done by using one of the classes in org.jdom.input. In this example, we'll use SAXBuilder: Listing 12. Parsing an XML file with SAXBuilder 
    try {
      SAXBuilder builder = new SAXBuilder();
      Document anotherDocument = 
        builder.build(new File("/some/directory/sample.xml"));
    } catch(JDOMException e) {
      e.printStackTrace();
    } catch(NullPointerException e) {
      e.printStackTrace();
    } You can manipulate the document built through this process in the same ways shown back in Listings 2 through 7.Another practical application of JDOM combines it with the Xalan product from Apache (see Resources). Using the car example above, we will construct a Web page for an online car dealer presenting the details of a particular car. First, we will assume that the document we built above represents the information about the car we are going to present to the user. Next, we will combine this JDOM Document with an XSL stylesheet and output the HTML-formatted results to a servlet's OutputStream for display in the user's browser.