Hi Krishna!

On Thu, 2009-06-18 at 18:15 +0530, Krishna Gopal Binyala wrote:
> I am using XMLBeans 2.2.0 for data binding in my web service; i.e.
> request and response.
> 
> If for some of the values in my response are null/ nil.. the response
> tag is coming as 
> 
> <Data xsi:nil="true"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
> 
> i don't want these nil value. the "Data" element is defined as 
>   <xsd:element name="Data" type="xsd:string" minOccurs="0"/>
> 
> please let me know how can i get rid fo these

Something like this should work:

XmlCursor cursor = mydoc().newCursor() ;
try {
   do { 
      if( cursor.isStart() && cursor.getObject().isNil() ) {
         cursor.removeXml() ;
      }
   } while( !cursor.toNextToken().isNone() ) ;
}
finally {
   cursor.dispose() ;
}

As cursor.removeXml() will remove the element, you may need to
experiment with the loop condition to make it full-proof.

Regards
Jeff
-- 
Jeff Lusted               tel: +44 (0)116 252 3581
Astrogrid Project         mob: +44 (0)7941 599062
Dept Physics & Astronomy  email: [email protected]
University of Leicester   web: http://www.astrogrid.org


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to