Hi,
How to I select the element and then get the content as JDOM Document?
Can give me some sample codes to see?
I don't use DOM at all.
I use the following program to get the value of Password element:
//----------------------------------------------------------------------
----
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/User");
String xpath =
"//[EMAIL PROTECTED]'[EMAIL PROTECTED]']/Password/text()";
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();
}
}
}
//----------------------------------------------------------------------
----
Thanks.
Regards.
-----Original Message-----
From: Vadim Gritsenko [mailto:[EMAIL PROTECTED]
Sent: [EMAIL PROTECTED]|8^, 5 三月, 2004 AM 1:22
To: xindice-users@xml.apache.org
Subject: Re: {SPAM?} Re: How to retrieve element's value only?
Chen Longtai wrote:
>I am running Xindice 1.0.
>
>Is there any problems?
>
>
Yes. This feature (non-element results) are supported by xindice
1.1b4-dev only.
To get value in xindice 1.0, select element and use getContentAsDOM
method, and traverse DOM.
Vadim
>-----Original Message-----
>From: Vadim Gritsenko [mailto:[EMAIL PROTECTED]
>Sent: [EMAIL PROTECTED]|;M, 4 三月, 2004 PM 11:28
>To: xindice-users@xml.apache.org
>Subject: Re: {SPAM?} Re: How to retrieve element's value only?
>
>Tan, Leong T wrote:
>
>
>
>>It does not work....
>>
>>
>>
>>
>
>Can you be more specific? Are you running current CVS or earlier
>version?
>
>
>
>>By replacing
>>String xpath = "//[EMAIL PROTECTED]'[EMAIL PROTECTED]']/Password";
>>With
>>String xpath = "//[EMAIL PROTECTED]'[EMAIL PROTECTED]']/Password/text()";
>>
>>
>>
>>
>
>
>Vadim
>