http://xml.apache.org/xerces-j/apiDocs/org/apache/xerces/dom/NodeImpl.html#toString()
If you check out the link above you will see toString() method should only be used for debugging purposes, and DOM standard has not such method.
You were not very clear about what you mean with "the whole XML tag". I suppose you want the tag name, the attributes with their values and the XML representation of it's childs and text nodes, i.e. a String serialization of a Node (wich is more generic than the serialization of just Elements's).
http://xml.apache.org/xalan-j/apidocs/org/apache/xml/serializer/DOMSerializer.html
Check out the above link and the related interface "SerializationHandler". This is a specific serializer from xalan.
http://java.sun.com/developer/community/chat/JavaLive/2002/jl0827.html
According the comments of Rajiv Mordani at the above link:
..."Currently, the way you can achieve the equivalent of |org.apache.xerces.serializer| is to use the Transform API from JAXP. Take a look at _the spec_ to see an example of how to use the transformer as a serializer. DOM Level 3 is going to have support for serialization, too"...
The example is at page 20 of the JAXP 1.2 final relase.
Cheers,
Adrian P.J.
LANTRES Franck wrote:
Hi,
I'm using JXPath for just one week to query flat XML files. While I do my unit tests, the soft is working well but as soon as it is included in the final environment based on Tomcat and servlet, it doesn't work. Searching where comes from this problem, I added logs and here is what I have found : To get the XML nodes matching a XPath query, I have written : JXPathContext ctx = JXPathContext.newContext(document); String query = "<some XPath query"; Pointer ptr = ctx.getPointer(query); return ptr.getNode().toString();
In standalone, the ptr.getNode() is a org.apache.crimson.tree.ElementNode and I get the whole XML tags as a string. Using Tomcat, the ptr.getNode() is a org.apache.xerces.dom.DeferredElementImpl and I get "null".
My first solution is to write a method to parse the NodeImpl and to create the XML as a string. Does exist a better solution ?
Thanks for your help.
Franck
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
