Hi
i am new to use java. on compling my java file in tomcat server i get

cannot resolve symbol
symbol  : method getAttribute (java.lang.String)
location: interface org.w3c.dom.Node
out.println(photoElements.item(iElement).getAttribute("id"));

and the line he is referring to is

for(int iElement = 1; iElement < 10; iElement++)
{
out.println(photoElements.item(iElement).getAttribute("id"));

i am not able to solve this error, kindly help.

Recommended Answers

All 2 Replies

It's saying that whatever class of object that is returned by photoElements.item(iElement) does not have a getAttribute(String) method. (Is id a variable? In which case it shouldn't have quotes round it). You need to look at the doc for photoElements.item to see what it returns, the look at that class's doc for details of getAttribute.

This line location: interface org.w3c.dom.Node would indicate it's returning a Node object but he's probably expecting an Element object.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.