You can also try [1]

[1]
http://mrmalakasilva.blogspot.co.uk/2014/03/how-to-remove-xml-elements-using-script.html

On Wed, Feb 4, 2015 at 6:01 PM, Buddhima Wijeweera <buddh...@wso2.com>
wrote:

> Hi,
>
> Following script will do the job:
>
> <script language="js">
> var fullContent =  mc.getPayloadXML();
> for(var index in  fullContent..*::advancedImageSearchVO.children()){
>
>
>     var b = fullContent..*::advancedImageSearchVO.children()[index];
>
>
>
>
>          if(b.toString() ==''){
>      delete fullContent..*::advancedImageSearchVO.children()[index];
>    }
>
>      }
>    mc.setPayloadXML(fullContent);
>
> </script>
>
> Thanks!
>
>
> On Wed, Feb 4, 2015 at 2:50 PM, Awanthika Senarath <awanth...@wso2.com>
> wrote:
>
>>
>> Hi,
>>
>> in trying to do $subject, i am using the script mediator as folows
>>
>> * <script language="js">*
>>
>> *var fullContent =  mc.getPayloadXML();  *
>> *var entity = mc.getPayloadXML()..*::entity;*
>>
>> *if (entity==null){*
>> *      fullContent.removeChild(entity);*
>> *   } *
>>
>> *mc.setPayloadXML(fullContent);*
>>
>> *</script>*
>>
>>
>> but my output always contains the empty tag <entity>
>>
>> sample xml output received
>>
>> Envelope:
>> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
>> http://www.w3.org/2003/05/soap-envelope";>
>> <soapenv:Body>
>> <ejb:getAdvancedDocumentReferenceList xmlns:ejb="
>> http://ejb.image.pfpc.com"; xmlns:vo="http://vo.image.pfpc.com";>
>> <ejb:provider>myProvidor</ejb:provider>
>>
>> <ejb:advancedImageSearchVO>
>>
>> <vo:departmentID>myID</vo:departmentID>
>> <vo:entity></vo:entity>         <--------- empty xml tag with no content
>>
>> </ejb:advancedImageSearchVO>
>>
>> </ejb:getAdvancedDocumentReferenceList>
>> </soapenv:Body>
>> </soapenv:Envelope>
>>
>>
>> where as the expected output shoud be
>>
>>
>> Envelope:
>> <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
>> http://www.w3.org/2003/05/soap-envelope";>
>> <soapenv:Body>
>> <ejb:getAdvancedDocumentReferenceList xmlns:ejb="
>> http://ejb.image.pfpc.com"; xmlns:vo="http://vo.image.pfpc.com";>
>> <ejb:provider>myProvidor</ejb:provider>
>>
>> <ejb:advancedImageSearchVO>
>>
>> <vo:departmentID>myID</vo:departmentID>
>>
>>
>> </ejb:advancedImageSearchVO>
>>
>> </ejb:getAdvancedDocumentReferenceList>
>> </soapenv:Body>
>> </soapenv:Envelope>
>>
>>
>>
>> can someone point out what I am doing wrong?
>>
>>
>> --
>> Awanthika Senarath
>> Software Engineer, WSO2 Inc.
>> Mobile: +94717681791
>>
>>
>>
>
>
> --
> Buddhima Wijeweera
> Software Engineer; WSO2 Inc.; http://wso2.com ,
>
> Mobile: +94 71 427 9966
> Email: buddh...@wso2.com
> Blog:   https://buddhimawijeweera.wordpress.com
> GitHub Profile: https://github.com/Buddhima
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 

Best Regards,

Malaka Silva
Senior Tech Lead
M: +94 777 219 791
Tel : 94 11 214 5345
Fax :94 11 2145300
Skype : malaka.sampath.silva
LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
Blog : http://mrmalakasilva.blogspot.com/

WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/
http://www.wso2.com/about/team/malaka-silva/
<http://wso2.com/about/team/malaka-silva/>

Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to