Search string in xmls

Hi All

The output of an adapter service is a document list which contains string — which inturn holds xml data.
I need a search for a particular string in the list of xmls.

One way i can think of is … loop over the results and then convert each xml to document and then search for string in the particular node.

But i do not want it this way, please suggest me any best way to optimize the code.

do u just want to check if the searchString exist or not ?

Guess u can write a java code as below which iterates over the documentlist.

public boolean search(IData searchDocument,String searchString)
{
IDataCursor idataCursor = searchDocument.getCursor();
while(idataCursor.hasMoreData())
{
Values idataHolder = new Values();
idataCursor.next();
String key = idataCursor.getKey();

if(idataCursor.getValue() instanceof IData)
{
for(IDataCursor secondCursor = ((IData)tempValue).getCursor(); secondCursor.hasMoreData();
idataHolder.put(secondCursor.getKey(), secondCursor.getValue()))
secondCursor.next();
}
else if(searchString.equals(idataCursor.getValue()))
{

     return true;

     }

}
return search(((IData) (idataHolder)));
}

Note that this code has not been tested and you might get minor errors while compilation.

Hi…
I need not just find a string in a documentList.

There is a documentList and a string beneath it. The string contains an XML.
I am looping over the documentList and converting the XML string to document and then searching if the string exists in a particular node.

Now is there any way to directly search for a string without looping over the documentList.

Thanks
Rocky

No. Just like an array in Java, you need to visit each entry in the list separately.

One thing you might be able to do is instead of converting each string to a node and the node to an IS document, you can use XQL to do the search on the node. If you’re looking for the speediest technique, be sure to measure which is faster.

Thanks Reamon !