[jdom-interest] Using JDOM to delete child elements

Jeff Ellman cb_elvis at hotmail.com
Wed May 22 13:11:54 PDT 2002


I want to use JDOM to delete an element and it’s children.  The element that 
I want to delete will be identified by the value given to one of its child 
elements.

Here’s a sample of an XML document that I pretty much have to work with:

<calendar>
  <!-- year attribute cannot be blank -->
  <year num="">
    <!-- month attribute cannot be blank -->
    <month num="">
      <event>
        <!-- Date value cannot be blank -->
        <date></date>
        <meetingName></meetingName>
      </event>
    </month>
  </year>
</calendar>

Here’s another look at the XML document in application:

<calendar>
  <!-- year attribute cannot be blank -->
  <year num="2001">
    <!-- month attribute cannot be blank -->
    <month num="12">
      <event>
        <!-- Date value cannot be blank -->
        <date>12</date>
        <meetingName>Meeting 1</meetingName>
      </event>
      <!-- I want to delete this next event element and it's children -->
      <event>
        <!-- Date value cannot be blank -->
        <date>12</date>
        <meetingName>Remove event based on this text</meetingName>
      </event>
    </month>
  </year>
</calendar>

How do I remove the even element based upon that event’s meetingName?
Any help in this matter would be greatly appreciated.  Thanks!

Sincerely,
Elvis


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.




More information about the jdom-interest mailing list