tags:

views:

68

answers:

1

For example, we have xml file with this format:

<A>
      <B>
            <C></C>
            <D></D>
            <D></D>
      </B>
</A>

i need that: if all "D"-tags elements are empty, then we need to delete whole "A"-tag element

and, of course, we need to do this with all "A"-tags in xml.

+1  A: 

Use this algorithm:

  • find all the B elements
  • for each B element, find all the D elements
  • for each D element, check if it's empty
  • if all D elements are empty, fetch the parent of B and remove it from the tree

To do it with the DOM extension, see:

Artefacto
thanks for great answer!but the best answer would be just an example of code ;)
cru3l
@cru3l: fyi, code snippets provided in answers are more likely when code snippets are provided in questions.
JYelton