Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How To View The Contents Of A Node

Posted on 2001-06-26
2
Medium Priority
?
215 Views
Last Modified: 2008-02-01
I have retrieved a node using Oracle Business Components for Java's writeXML method, and I'd like to view its contents.

I have tried to append it to a document (so that I can use xmlOutput.output(document, System.out) to view the node) using appendChild(node), but I get this error:

org.apache.crimson.tree.DomEx: WRONG_DOCUMENT_ERR: That node doesn't belong in this document.

I have also tried to import the node using importNode(node, boolean) but I get this error:

java.lang.IllegalArgumentException: Node is not a rg.apache.crimson.tree implementation.

Lastly, I have tried this:

javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource(xmlNode);
javax.xml.transform.TransformerFactory txnfac = javax.xml.transform.TransformerFactory.newInstance();
File xslfile = new File("C:\\xml\\testoutput.xsl");
StreamSource xslsource = new StreamSource(xslfile);
javax.xml.transform.Transformer txn = txnfac.newTransformer(xslsource);
txn.transform(domSource, new StreamResult(new FileOutputStream("C:\\xml\\result.xml")));

but then I get this error:

java.lang.AbstractMethodError
void org.apache.xalan.transformer.TransformerImpl.transform(javax.xml.transform.Source, javax.xml.transform.Result)

Any help would be greatly appreciated.
0
Comment
Question by:janey88
2 Comments
 
LVL 10

Accepted Solution

by:
Yury_Delendik earned 225 total points
ID: 6227358
You can't use neither appendChild nor importNode.

Try
  javax.xml.transform.TransformerFactory txnfac = javax.xml.transform.TransformerFactory.newInstance();
  javax.xml.transform.Transformer txn = txnfac.newTransformer();
  txn.transform(new javax.xml.transform.dom.DOMSource(yourSourceNode), new javax.xml.transform.dom.DOMResult(yourParentNode));

{ and same }
javax.xml.transform.TransformerFactory.newInstance().newInstance().transform(new javax.xml.transform.dom.DOMSource(yourSourceNode), new javax.xml.transform.dom.DOMResult(yourParentNode));
0
 

Author Comment

by:janey88
ID: 6233751
I tried the code you posted, but there's still an Abstract Method Error.  Anyway, I found a new API that has a method that converts a node directly into a String.  But thanks for your response!  =)



0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Integration Management Part 2

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question