Find empty elements

Questions about XML that are not covered by the other forums should go here.
escarole
Posts: 2
Joined: Sat Jun 09, 2007 6:41 pm
Location: Atlanta, Ga.

Find empty elements

Post by escarole »

Does Oxygen have any tools that would help me find empty elements (and possibly remove them all) in a large document?

The application that created this document makes lots of empty elements for fields in which someone doesn't enter data.

(Newby here)
escarole
Posts: 2
Joined: Sat Jun 09, 2007 6:41 pm
Location: Atlanta, Ga.

Post by escarole »

Or, of Oxygen doesn't, can someone suggest something else?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

You can remove the empty elements by executing a Find/Replace with the following regexp as the find expression: <([^</>"=]+?)>(\s*?)</(.+?)> and the empty string as the replace expression. This works for elements in the form:

Code: Select all

<elem1>   </elem1>
and

Code: Select all

<elem2>

</elem2>
For elements of the form:

Code: Select all

<elem3 />
you should use the find expression: <([^</>"=]+?)/>


Regards,
Sorin
Post Reply