Page 1 of 1

accessing akward attribute

Posted: Wed Jul 26, 2006 1:35 am
by jher
Hello

I have an xml document that looks similar to this template
<Library>
<book bookNum ="1" bookLength="300">
<author> some dude </author>
</book>
<book bookNum ="2" bookLength="100">
<author> anouther guy </author>
</book>

etc...

</Library>

My question is how do i get the attribute book Length from the first book?

The information is held on an XML database and my query looks like this

Select *
From MYTABLE
WHERE extractValue(OBJECT_VALUE, 'Library/book[1][@bookLength]') == 100;


I basically want to extract all the libraries from my database that contain a book of 100 pages.

Can anyone help?

Thanks

Posted: Wed Jul 26, 2006 10:05 am
by sorin_ristache
Hello,

I think you need Library/book[1]/@bookLength instead of Library/book[1][@bookLength]. This is the expression for the bookLength attribute of the first book. If you want to test that there is at least a book with 100 pages you need Library/book[@bookLength = '100']

Regards,
Sorin

Posted: Wed Jul 26, 2006 6:41 pm
by jher
Thanks sorin

That worked like a charm :)