Java Remove empty XML tags

前端 未结 9 2349
死守一世寂寞
死守一世寂寞 2020-12-11 16:57

I\'m looking for a simple Java snippet to remove empty tags from a (any) XML structure


    bla
    <         


        
9条回答
  •  离开以前
    2020-12-11 17:38

    As a side note: The different states of a tag actually have meaning:

    • Open-Closed Tag: The element exists and its value is an empty string
    • Single-Tag: The element exists, but the value is null or nil
    • Missing Tag: The element does not exist

    So, by removing empty Open-Closed tags and Single-Tags, you're merging them with the group of missing tags and thus lose information.

提交回复
热议问题