This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes XML and Related Technologies and the fly likes XQuery basic question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XQuery basic question" Watch "XQuery basic question" New topic
Author

XQuery basic question

biraji gafiff
Greenhorn

Joined: Jul 11, 2005
Posts: 27
Hi everyone, i have two xml tags named "book" with "author_id" attribute and "author" with "id" attribute (among others), suppose that i want the name of the author who wrote a specific book, how could i do that?

Thanks in advance.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, the XPath expression would be something like this:That would work if you were using XML tools that supported XPath.

Edit: I just noticed you had the word "XQuery" hidden in the title of your post. I don't know XQuery but maybe it supports XPath, or maybe you can adapt that expression to work in it.
[ May 27, 2007: Message edited by: Paul Clapham ]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Paul Clapham:
That would work if you were using XML tools that supported XPath.


Hi Paul, How are you using tags like name and title.Nothing is mentioned about those in the initial post.

For the XML below:



use the following XPath.



Tested using XPath Explorer eclipse plugin.


Rahul Bhattacharjee
LinkedIn - Blog
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Originally posted by Rahul Bhattacharjee:
Hi Paul, How are you using tags like name and title.Nothing is mentioned about those in the initial post.
That's true. The initial post didn't mention anything about where the name and title were coming from, so I made a guess. That is often easier than asking the poster to provide useful details. If the guess is wrong, the poster can then respond with those details.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Paul Clapham:
That's true. The initial post didn't mention anything about where the name and title were coming from, so I made a guess. That is often easier than asking the poster to provide useful details. If the guess is wrong, the poster can then respond with those details.


Thats very true.I was think that I am missing something.
;)
 
wood burning stoves
 
subject: XQuery basic question