xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dane Foster" <dfos...@equitytg.com>
Subject Problem with Attributes
Date Tue, 23 Jan 2001 19:04:23 GMT
I'm parsing an XML document using SAX2 and I'm having a bit of trouble getting data using the
Attributes interface.  Here is quick codelet of what I'm doing:

Note: Assume that the XML document is valid and therefore cannot be the cause of the error.

// objectStack is a member variable of type java.util.Stack

public void startElement( String a, String b, String c, Attributes atts ) throws SAXException
{
    if( c.equals( "elementName" ) ) objectStack.push( atts );
    // other if/else statements follows but doesn't affect what I'm describing
}

public void endElement( String a, String b, String c ) throws SAXException
{
    if( c.equals( "elementName" ) )
    {
        Attributes att = (Attributes)objectStack.pop();

        String var1 = att.getValue( "variable_one" );
        String var2 = att.getValue( "variable_two" );
    }
}

The problem is att.getValue( "param" ) returns null so when I go to use var1 and/or var2 a
NullPointerException is thrown.  Any help would be greatly appreciated.




Dane Foster
http://www.equitytg.com.


Mime
View raw message