Taken from the "Addressbook" example :
after getting the node from Xindice you can execute Xpath request to have
the value :
<code>
while (results.hasMoreResources()) {
.... snip ....
XMLResource resource = (XMLResource) results.nextResource();
// Cast to Dom Node
Node originalnode = resource.getContentAsDOM();
.... snip ....
XObject xo = new XObject(); // note from poster : bahhh this initialization
will be scratched by the following ;-)
.... snip .....
xo = XPathAPI.eval(originalnode, "/person/[EMAIL PROTECTED]'work']");
person.setWorkPhone(xo.toString());
</code>I hope it helps, Julien ----- Original Message ----- From: "Matthew Van Horn" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Thursday, December 12, 2002 2:56 AM Subject: Re: Retrieving Attribute Values > > On Thursday, December 12, 2002, at 03:37 AM, Paul J. Caritj wrote: > > > Greetings, > > I have what I hope is a rather simple question, but I have been unable > > to find specific examples of how to do this in the documentation > > (perhaps it should be added). > > > > How does one select the value of an attribute node? > > To clarify further - my understanding is that Xindice returns only XML. > The value of an attribute by itself is not valid XML. > Therefore Xindice will not return attribute values. > It makes sense if you think about it a while. > > considering: > <root> > <item id="1" name="brick"/> > <item id="2" name="brick"/> > </root> > > 1 <- not valid XML > id=1 <- not valid XML > @id=1 <- not valid XML > > Valid XML: > <?xml version="1.0"?> > <item xmlns:src="http://xml.apache.org/xindice/Query" > src:col="/db/bricks" > src:key="1" id="1" name="brick"></id> > > So let your program extract the attributes from the results returned. > > >
