Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Document in Xindice

Status
Not open for further replies.

Davc

Technical User
Apr 30, 2002
8
IE
I am trying to manipulate an xml document i placed within the addressbook collection in Xindice(Native XML Database). I'm attempting to match the value contained within the email attribute in the departmental-office element. The program compiles but I'm not getting any output. Can you see where I'm going wrong?

Many thanks,

David



import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;

public class test {
public static void main(String[] args) throws Exception {
Collection col = null;
try {
String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
Class c = Class.forName(driver);

Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);

col = DatabaseManager.getCollection("xmldb:xindice:///db/addressbook");

String xpath = "//Departmental_Office";
XPathQueryService service =
(XPathQueryService) col.getService("XPathQueryService", "1.0");
ResourceSet resultSet = service.query(xpath);
ResourceIterator results = resultSet.getIterator();
while (results.hasMoreResources()) {
Resource res = results.nextResource();
System.out.println((String) res.getContent());
}
}
catch (XMLDBException e) {
System.err.println("XML:DB Exception occured " + e.errorCode);
}
finally {
if (col != null) {
col.close();
}
}
}
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top