How To Remove Empty XML Tags?

E

eric.jester

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
 
E

enrique

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?
 
E

eric.jester

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

Thanks,

Eric
 
E

enrique

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top