How To Remove Empty XML Tags?

Discussion in 'Java' started by eric.jester@gmail.com, Apr 20, 2005.

  1. Guest

    Hi,

    I have a middleware application that is outputting empty xml tags when
    no value is present for an element (<element1></element1>). I need to
    remove these empty tags somehow. Is this possible using DOM or XPATH?
    I have been looking at the api's and haven't seen anything capable of
    this.

    Thanks,

    Eric
     
    , Apr 20, 2005
    #1
    1. Advertising

  2. enrique Guest

    Using xslt you can transform your generated xml to ignore the empty
    tags as it rewrites the document. Just echo out the original document,
    except for the one rule for processing empty tags. Are you familiar
    with writing rules for xslt?
     
    enrique, Apr 20, 2005
    #2
    1. Advertising

  3. Guest

    Enrique, unfortunately I am not familiar with that. Can you provide
    some guidance?

    Thanks,

    Eric
     
    , Apr 21, 2005
    #3
  4. enrique Guest

    Yes, the shortest answer is to familiarize yourself with XSLT.
    Download an XSLT processor, like one from apache.org. I think it's
    called Xerces.

    The jist of it is that you write certain rules that specify how you
    want to transform an XML document. In your case, you basically want
    the same document minus the empty tags. Your rule should be very
    simple to write, if you know the basics of writing XSLT.
     
    enrique, Apr 25, 2005
    #4
    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. Jander
    Replies:
    1
    Views:
    334
    Sudsy
    Jun 14, 2004
  2. yzzzzz
    Replies:
    3
    Views:
    504
    Wendy S
    Jan 28, 2005
  3. Lukas
    Replies:
    3
    Views:
    817
    spiff
    Nov 10, 2005
  4. Replies:
    1
    Views:
    662
    Henry S. Thompson
    Dec 21, 2005
  5. David

    Remove Empty Tags on page

    David, May 26, 2008, in forum: Javascript
    Replies:
    15
    Views:
    223
    Michael Wojcik
    May 28, 2008
Loading...

Share This Page