XML element removal

Last post 12-24-2009 11:29 AM by jdd. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 12-17-2009 11:32 PM

    XML element removal

    Hi,

    We have a requirement to transform from a source xml to terget xml. The scenario is, the source xml has a leaf node and few nodes. If the value in the leaf is False I shouldnot generate the nodes under the parent node.

    Example:

    Source XML

    <Student>

           <AssignedCourse>False</AssignedCourse>

                <CourseDetails>

                      <CourseName>JAVA</CourseName>

                      <CourseID>1</CourseID>

             </CourseDetails>

    </Student>

    Desired output: 

    If AssignedCourse is False I want to generate the following XML,

     <Student>

           <AssignedCourse>False</AssignedCourse>

      </Student>

     

    I could not achieve the above with the help of Reject or Discard functions as they generate the following output which is not desired,

    <Student>

           <AssignedCourse>False</AssignedCourse>

          </CourseDetails>

      </Student>

     

    Appreciate your help

     

    Regards

    Karthik

  • 12-24-2009 11:26 AM In reply to

    • jdd
    • Top 25 Contributor
    • Joined on 04-04-2005
    • Posts 363

    Re: XML element removal

    Simplest way would be to use an XSLT step or X-Path Invoker. Are you familiar with either of these?

  • 12-24-2009 11:29 AM In reply to

    • jdd
    • Top 25 Contributor
    • Joined on 04-04-2005
    • Posts 363

    Re: XML element removal

    Actually, shouldn't be that difficult in a map. Just need flag variables that will be put into the Count parameter of your ClearMapPut of the child nodes. set the flags to zero if the parent is False.

Page 1 of 1 (3 items)