Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

read an XML file with java: Document to Node conversion

843834Nov 27 2002 — edited Jan 14 2003
Hello,

I want to read an XML file and convert data into a Node instance because I need this for an XForm application.

My code is:

private Node workstationType;

public Node initModel() {
try {
//This one will hold the results
Document document;

//loading from XML File
String fileName="C:\\documents\\iniForm.xml";
FileInputStream inXML = new FileInputStream(fileName);
BufferedReader in = new BufferedReader(new InputStreamReader(inXML));
document = XMLLoader.loadFromStream(in);
} catch (Exception e) {
System.err.println("ERROR:" + e.getMessage());
e.printStackTrace(System.err);
}

//Create the node for the root, 'typeOfWorkstation'
workstationType = document.getDocumentElement(); //A

//Return the root node
return (workstationType);
}


The problem: I can convert Node instance to Document instance (line A)
The error message is: "document cannot be resolved".

How can I do that??

Thank you
Sylvain
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 11 2003
Added on Nov 27 2002
9 comments
2,605 views