XML to string
i got an xml doc of 10 record nodes.
with the help of a java program i parsed that and queried and retrieved 3 out of 10.
now i want to convert this 3 node to a string
i wrote an function which used xsl transformers to convert but it accepts only document, and if i used Document d = node.getParentDocument() it returns the whole xml document and if i use
Document d = ( Document ) node;
it throws an exception classcastexception.
how to convert that xml node to a document so that i can pass it to my function which uses Xsl transformers to convert.
if there s any other method to do that please help by telling my that
If you are using java then there is a obj.toString() method that you can apply at element/node level or another crude way of doing what you want is to create a new document and append the node to it and print it..
A Document is not a node in and of itself, which is why the caste fails, you need to call document.documentElement() to get the root node of your document, then you can use that to do what you want (but remember, it will be an element, not a node, so you will have to still caste it to type node).
should return the root of the doc as a node reference.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)