Hi! It’s me again!
A small question to ask this time:
if(response.hasFirstXMLObject())
{
StringWriter stringWriter = new StringWriter();
response.getFirstXMLObject().writeTo(stringWriter);
System.out.println("Retrieve following instance: ");
System.out.println(stringWriter);
}
else
System.out.println(“No instance found”);
This small part of the codes, does it just store only the first result? If my query statement suppose to return 3 results, will the program show it, even though they are far apart?
-KAren-
:o
Hi,
If I understand your question correctly, you need to iterate through your response like this:
<BR>if ( response.hasFirstXMLObject() ) {<BR> TXMLObjectIterator myIterator = response.getXMLObjectIterator();<BR> while (myIterator.hasNext()) {<BR> TXMLObject xmlObjectReturned = myIterator.next();<BR>... process each xmlObjectReturned here ...<BR> }<BR>}<BR>
Heya Bill,
By using TXMLObjectIterator, it is better than before. It return 3 instances, which is correct. Unfortunately, those 3 instances are the same, ie: 19, 19, 19
By right, it should show: 19, 45, 88
I was thinking why it kept reading ID 19. Does it affect if these 3 ID are found in different document? Meaning, all 3 IDs have different ino:id.
A little background:
The data I have is actually stored in a single xml file. When I tried to upload it using Tamino Interactive Interface, it went timeout. My guess was, the file was too big, so I broke it up into 4 parts. As I uploaded them one by one, each file have different ino:id.
Do you think that is why is not reading the other IDs?? Then again, the program returned 3 instances…hmmm??
-KAren-
Hi again,
I may be wrong on the ino:id. My second guess is the response.getFirstXMLObject(), for it only retrieve the first object.
if(response.hasFirstXMLObject())
{
TXMLObjectIterator myIterator = response.getXMLObjectIterator();
System.out.println("Retrieve following instance: ");
response.getFirstXMLObject().writeTo(stringWriter);
while (myIterator.hasNext())
{
TXMLObject xmlObjectReturned = myIterator.next();
response.getFirstXMLObject().writeTo(stringWriter);
count++;
}
}
else
System.out.println(“No instance found”);
-KAren-
I reckon your second guess is right.
TXMLObject xmlObjectReturned = myIterator.next();
xmlObjectReturned.writeTo(stringWriter);
should work.