469,890 Members | 2,321 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

Help with XPath query

Hello All,

I am trying to construct an XPath query against an XML document, for a
requirement that I have. Below is the XML fragment:

<SUBMISSIONS>
<SUBMISSION YEAR="2004">
<MONTH NAME="JAN">10</MONTH>
<MONTH NAME="FEB">02</MONTH>
Mar 5 '07 #1
2 1377
xquery is case sensitive, use "and"

-- bruce (sqlwork.com)

Diffident wrote:
Hello All,

I am trying to construct an XPath query against an XML document, for a
requirement that I have. Below is the XML fragment:

<SUBMISSIONS>
<SUBMISSION YEAR="2004">
<MONTH NAME="JAN">10</MONTH>
<MONTH NAME="FEB">02</MONTH>
.
.
<MONTH NAME="DEC">78</MONTH>
</SUBMISSION>
<SUBMISSION YEAR="2005">
<MONTH NAME="JAN">03</MONTH>
<MONTH NAME="FEB">50</MONTH>
.
.
<MONTH NAME="DEC">27</MONTH>
</SUBMISSION>
<SUBMISSION YEAR="2006">
<MONTH NAME="JAN">34</MONTH>
<MONTH NAME="FEB">65</MONTH>
.
.
<MONTH NAME="DEC">22</MONTH>
</SUBMISSION>
<SUBMISSIONS>

If a user selects a time-period from 01-MAR-2005 to 31-DEC-2006, I have to
display month-wise counts for each of those months. i.e., I have to add March
of 2005 and March of 2006, April of 2005 and April of 2006 and so on and so
forth. and display the grand totals for individual months during that time
period. As part of this requirement, I wrote the following XPath query to get
the nodes for "NOV" from any of the years 2005.

"/SUBMISSIONS/SUBMISSION[@YEAR >= 2005]/MONTH[@NAME='NOV']"

But what I really need is the time period from 2005 to 2006; and when I try
the below query to get the nodes between this time period, I get "invalid
token" error message:

"/SUBMISSIONS/SUBMISSION[@YEAR >= 2005 AND @YEAR <= 2006]/MONTH[@NAME='NOV']"

Is not this a valid Xpath query? Cannot I specify lower bound and upper
bound simultaneously in an Xpath query? If I give only one predicate it works
fine...

Help!!!!

Mar 5 '07 #2

Thanks Bruce...that did the trick!

I changed "AND" to "and" and it worked like a charm.

"bruce barker" wrote:
xquery is case sensitive, use "and"

-- bruce (sqlwork.com)

Diffident wrote:
Hello All,

I am trying to construct an XPath query against an XML document, for a
requirement that I have. Below is the XML fragment:

<SUBMISSIONS>
<SUBMISSION YEAR="2004">
<MONTH NAME="JAN">10</MONTH>
<MONTH NAME="FEB">02</MONTH>
.
.
<MONTH NAME="DEC">78</MONTH>
</SUBMISSION>
<SUBMISSION YEAR="2005">
<MONTH NAME="JAN">03</MONTH>
<MONTH NAME="FEB">50</MONTH>
.
.
<MONTH NAME="DEC">27</MONTH>
</SUBMISSION>
<SUBMISSION YEAR="2006">
<MONTH NAME="JAN">34</MONTH>
<MONTH NAME="FEB">65</MONTH>
.
.
<MONTH NAME="DEC">22</MONTH>
</SUBMISSION>
<SUBMISSIONS>

If a user selects a time-period from 01-MAR-2005 to 31-DEC-2006, I have to
display month-wise counts for each of those months. i.e., I have to add March
of 2005 and March of 2006, April of 2005 and April of 2006 and so on and so
forth. and display the grand totals for individual months during that time
period. As part of this requirement, I wrote the following XPath query to get
the nodes for "NOV" from any of the years 2005.

"/SUBMISSIONS/SUBMISSION[@YEAR >= 2005]/MONTH[@NAME='NOV']"

But what I really need is the time period from 2005 to 2006; and when I try
the below query to get the nodes between this time period, I get "invalid
token" error message:

"/SUBMISSIONS/SUBMISSION[@YEAR >= 2005 AND @YEAR <= 2006]/MONTH[@NAME='NOV']"

Is not this a valid Xpath query? Cannot I specify lower bound and upper
bound simultaneously in an Xpath query? If I give only one predicate it works
fine...

Help!!!!
Mar 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by 0wl | last post: by
8 posts views Thread by Terry P | last post: by
4 posts views Thread by gfrommer | last post: by
1 post views Thread by Brad Hehe | last post: by
7 posts views Thread by Ot | last post: by
10 posts views Thread by Michael C# | last post: by
5 posts views Thread by Gnic | last post: by
6 posts views Thread by dotnetnoob | last post: by
3 posts views Thread by Jason Mobarak | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.