Forum Stats

  • 3,854,920 Users
  • 2,264,431 Discussions
  • 7,905,832 Comments

Discussions

Searching for attributes

843834
843834 Member Posts: 49,972
edited Jun 15, 2001 11:13AM in Java Technology & XML
I'm using SaxParser and trying to identify an attibute, the line in the xml document looks like this:
<question id="q001" type="single_answer" status="enable">

In my parser I've tried to locate the "type" attribute
with:
public void startElement (String uri, String name,
String qName, Attributes atts)
{
//System.out.println("Start element: {" + uri + "}" + name);
////////////////////////////////////////////////////////////////////////////////////////////////////

String question_type = atts.getType("id");
System.out.println(question_type);

if( name.equals("question_text")){
XMLquestion_text_counter++;
System.out.println(XMLquestion_text_counter);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////

}

Keeps coming back null
Can anyone shed some light on why?
Learning this as I go.
Thanks
Jim

Comments

This discussion has been closed.