xml parser for filterig empty tags

Discussion in 'Java' started by Jander, Jun 14, 2004.

  1. Jander

    Jander Guest

    I'm parsing an xml file with SAXParser ,i extended DefaultHandler for
    parsing it ,so my bean overrides several methods as

    startDocument()
    endDocument()
    startElement()

    ....

    my tarjet is filtering empty tags in my xml files ,but with this method
    i can't do that with this methods .

    What other aproach migth use ?
    Any ideas ?

    Thanks
    Jander, Jun 14, 2004
    #1
    1. Advertising

  2. Jander

    Sudsy Guest

    Jander wrote:
    > I'm parsing an xml file with SAXParser ,i extended DefaultHandler for
    > parsing it ,so my bean overrides several methods as
    >
    > startDocument()
    > endDocument()
    > startElement()
    >
    > ...
    >
    > my tarjet is filtering empty tags in my xml files ,but with this method
    > i can't do that with this methods .


    Sure you can: you just have to think the problem through. If the methods
    are called in the following order then there is content:
    startElement()
    characters()
    endElement()
    However, this order would suggest an empty element:
    startElement()
    endElement()
    So perhaps you set a boolean in the startElement method and clear it in
    the characters method. When you get to the endElement method you check
    the variable: if set then element was empty.
    Sudsy, Jun 14, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob Foster
    Replies:
    0
    Views:
    419
    Bob Foster
    Jul 30, 2003
  2. Lukas
    Replies:
    3
    Views:
    789
    spiff
    Nov 10, 2005
  3. arne
    Replies:
    0
    Views:
    344
  4. Sean
    Replies:
    3
    Views:
    254
    robic0
    Oct 3, 2006
  5. Sean
    Replies:
    0
    Views:
    359
Loading...

Share This Page