You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Alex Chew <ch...@gmail.com> on 2006/06/19 05:13:33 UTC
Can Resource.getContent() return a Map object directly?
Hi, everybody
In my project, I want to use a query result just like
java.util.Map. But Resource.getContent() just return a raw XML String. Does
there some method can convert a query result into a Map object? Then i can
use like this,
I tried now,
while (resourceIterator.hasMoreResources()) {
Resource resource = resourceIterator.nextResource();
//I must extract each value, element and attribute, here. It looks some
stranges and runs slowly
System.out.println((String) resource.getContent());
}
I want it can work like this,
while (resourceIterator.hasMoreResources()) {
Resource resource = resourceIterator.nextResource();
Map result = resource.getMap();
//then i can get specified value just use result.get("key")
}
thanks.
alex
Re: Can Resource.getContent() return a Map object directly?
Posted by Alex Chew <ch...@gmail.com>.
Thanks.
It resolved.
I retrived what i want using DOM4J while iterating ResourceIterator.
Alex.
Re: Can Resource.getContent() return a Map object directly?
Posted by Vadim Gritsenko <va...@reverycodes.com>.
Alex Chew wrote:
> Hi, everybody
>
> In my project, I want to use a query result just like
> java.util.Map. But Resource.getContent() just return a raw XML String.
> Does there some method can convert a query result into a Map
> object? Then i can use like this,
Nope, not possible. XML:DB api provides a way to access binary data and XML
documents, no support for maps.
> I tried now,
> while (resourceIterator.hasMoreResources()) {
> Resource resource = resourceIterator.nextResource();
> //I must extract each value, element and attribute, here. It looks some
> stranges and runs slowly
> System.out.println((String) resource.getContent());
> }
>
> I want it can work like this,
> while (resourceIterator.hasMoreResources()) {
> Resource resource = resourceIterator.nextResource();
> Map result = resource.getMap();
> //then i can get specified value just use result.get("key")
> }
Why don't you query the database and retrieve only the relevant document fragments.
Vadim