read an XML file with java: Document to Node conversion
843834Nov 27 2002 — edited Jan 14 2003Hello,
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