Results 1 to 3 of 3
  1. #1
    sanderstad is offline Member
    Join Date
    Aug 2011
    Posts
    5
    Rep Power
    0

    Default End Element exception reading XML file

    Hi Guys,

    I have an issue with reading an XML file that contains several elements.
    The application will try to read the elements but on a certain point the application can't load the next start element. At least I think this is the issue.

    I get the following error:
    ------------------------------------------------------------------------------
    Start document
    Exception in thread "main" java.lang.NullPointerException
    at Test03.endElement(Test03.java:135)
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.endElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanEndElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDriver.next(Un known Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.parse(Unknown Source)
    at Test03.main(Test03.java:46)
    ------------------------------------------------------------------------------

    Can anybody tell me what I'm doing wrong here?
    For the easy part of it I included the files as an attachment to the post.

    Test03.zip

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: End Element exception reading XML file

    Because you never create a ArrayList.
    You have declared the list, but thats all so you will get this exception in your endElement method (at Test03.endElement(Test03.java:135)) at piList.add(tempPI); and ppList.add(tempPP); (both lists are null)

  3. #3
    sanderstad is offline Member
    Join Date
    Aug 2011
    Posts
    5
    Rep Power
    0

    Default Re: End Element exception reading XML file

    OMG I totally overlooked that one.

    It's true that once you look at your code too long you don't see the small issues which get you stuck.

    Thank you!

Similar Threads

  1. First Element of Array being written to file twice Help
    By kingkongjaffa in forum New To Java
    Replies: 1
    Last Post: 08-16-2011, 12:10 AM
  2. Reading from file - NullPointer exception
    By Sage25 in forum New To Java
    Replies: 5
    Last Post: 07-08-2010, 05:34 PM
  3. Replies: 9
    Last Post: 10-20-2009, 10:52 AM
  4. Replies: 3
    Last Post: 05-09-2009, 11:31 PM
  5. a no such element exception
    By headlice1 in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •