accessing akward attribute

Questions about XML that are not covered by the other forums should go here.
jher
Posts: 2
Joined: Wed Jul 26, 2006 1:30 am

accessing akward attribute

Post 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
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post 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
jher
Posts: 2
Joined: Wed Jul 26, 2006 1:30 am

Post by jher »

Thanks sorin

That worked like a charm :)
Post Reply