dcsimg
cannot resolve symbol..error
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Suchismita_Chatterjee
Posted On:   Sunday, February 16, 2003 09:00 PM

Hi , I have this code.. public class UseDom { public static Document createRootElement() { try { //Creates document builder factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true); //Tells the parser to be namespace aware factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); //Creates element as root element Element xmlfile = doc.createElement("xml"); //Sets the element as root doc.appendChild(xmlfile); } catch (IOException e) { e.printStackTrace(); }   More>>

Hi ,
I have this code..

public class UseDom {
public static Document createRootElement() {
try {
//Creates document builder factory
DocumentBuilderFactory
factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
//Tells the parser to be namespace aware
factory.setNamespaceAware(true);
DocumentBuilder
builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();

//Creates element as root element
Element xmlfile = doc.createElement("xml");
//Sets the element as root
doc.appendChild(xmlfile);

} catch (IOException e)
{
e.printStackTrace();
}
return doc;
}.....

when i am compiling..i get this error..abt my return statement..that it cannot resolve symbol dod..why is that??

$ javac UseDom.java
UseDom.java:41: cannot resolve symbol
symbol : variable doc
location: class UseDom
return doc;

Can someone plss help..wld really appreciate it.
thanks a lot

   <<Less

Re: cannot resolve symbol..error

Posted By:   vinay_salehithal  
Posted On:   Monday, February 17, 2003 07:53 AM

Check yr code. It seems that you are declaring "doc" inside try block but refering(while return) to it from outside.

One way to solve this wd be to move the doc variable declaration outside try.
About | Sitemap | Contact