Hi Javier,

> System.out.println(elem.getTextContent());

This function will only give you the text content (or, in XQuery
terminology, the "string value") of an element. This means that all
newly created marker elements will be stripped. You will have to
serialize your element by e.g. calling
DOMImplementationLS.createLSSerializer.

Avoiding the DOM conversion gives you much better performance. This is
one way to do it:

    QueryProcessor proc = new QueryProcessor(query, context);
    // loop through all results
    for(Item item : proc.value()) {
      // check if result is a node
      if(item instanceof ANode) {
        // print children of node (elements, texts, etc.)
        for(final ANode child : ((ANode) item).children()) {
          System.out.print(child);
        }
        System.out.println();
      }
    }
    proc.close();

Hope this helps,
Christian




[1] 
http://docs.oracle.com/javase/6/docs/api/org/w3c/dom/Node.html#getTextContent()

Reply via email to