Hi,
Traverse through the document using the webMethods java API. You can then use the IDataCursor’s getKey()
method to get the key of the document. Then passing the IDataCursor object and the key to the IDataUtil’s get method to obtain the value
of the document element as an object. Then use the java’s instanceof keyword to compare and check the
datatype of the documents element.
Suppose if you document has the following elements with String, Integer, Date, BigInteger datatypes…
doc
Name - (String datatype)
Age - (Integer datatype)
JoinDate - (Date datatype)
Salary - (BigInteger datatype)
Below is a sample code snippet…
[highlight=java]
IDataCursor _cursor = pipeline.getCursor() ;
IData _data = IDataUtil.getIData(_cursor,“doc”) ;
IDataCursor _datacursor = _data.getCursor() ;
//move the cursor to the first element in the document
_datacursor.first();
while(_datacursor.hasMoreData())
{
String _strKey = _datacursor.getKey() ;
Object _obj = IDataUtil.get(_datacursor,_strKey) ;
if(_obj instanceof java.lang.String)
{
//do processing here
}
else if(_obj instanceof java.lang.Integer)
{
//do processing here
}
else if(_obj instanceof java.util.Date)
{
//do processing here
}
else if(_obj instanceof java.math.BigInteger)
{
//do processing here
}
//move the cursor to the next element in the document
_datacursor.next();
}
//Finally destroy the cursor’s at the end of the java service
_datacursor.destroy() ;
_cursor.destroy() ;[/highlight]
Note that java’s instanceof keyword can only be used with the non-primitive datatypes.
Thanks
sivaram