xml file parsing using DocumentFactory
Hai ,
I dont know how to read an xml document using DocumentFactory ..
i am using netbeans and jdk1.6. do i have to download any jar files and put those in lib. Can any one tell me what i have to fallow.
my sample code is:
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.lang.*;
public class Info extends Object {
public static void main (String args[])
{
String myFile = "C://myinfo.xml";
//Initialize the DOM Object
Document myDoc = null;
try {
DocumentBuilderFactory docbuilderfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docbuilder = docbuilderfactory.newDocumentBuilder();
myDoc = docbuilder.parse(myFile);
System.out.println(myDoc);
} catch (Exception e) {
e.printStackTrace();
System.err.println("Cannot read the file: "+e.getMessage());
}
}
}
i can compile but at the run time i am not able read the "C://myinfo.xml"
Any one having idea on this kindly guide me

