Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How To Remove Empty XML Tags?

Reply
Thread Tools

How To Remove Empty XML Tags?

 
 
eric.jester@gmail.com
Guest
Posts: n/a
 
      04-20-2005
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

 
Reply With Quote
 
 
 
 
enrique
Guest
Posts: n/a
 
      04-20-2005
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?

 
Reply With Quote
 
 
 
 
eric.jester@gmail.com
Guest
Posts: n/a
 
      04-21-2005
Enrique, unfortunately I am not familiar with that. Can you provide
some guidance?

Thanks,

Eric

 
Reply With Quote
 
enrique
Guest
Posts: n/a
 
      04-25-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DetailsView ASP Control and an empty field not an empty record. ButlerDJIAM ASP .Net 0 11-09-2006 06:40 PM
Altova Mapforce - xml 2 xml map: empty elements output although input element is not empty Lukas XML 3 11-10-2005 02:25 PM
empty lists vs empty generators Brian Roberts Python 12 05-04-2005 08:59 PM
Check if a directory is empty and empty it Marcia Hon C Programming 8 02-14-2004 03:53 AM
empty/non-empty element John XML 1 07-16-2003 10:23 AM



Advertisments