By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,457 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,457 IT Pros & Developers. It's quick & easy.

xpath again - not xslt ? but to select node in asp.net

P: n/a
Hi again,

I'm using the following xpath (works in visualizer) with a
SelectSingleNode("xpath") statement.

//Station[@name="Station1"]/(WI[Boards/Board[@sn="583230"][@finish]])[la
st()]]/@order

Problem is I get an error "expression passed to this method should
result in a NodeSet". Of course, that (sort of) makes sense to me now (I
suppose just an attribute couldn't be a nodeset, but how would I go
about:

I need to determine if and what <WI> element is the parent of the last
<Board> is according to the above xpath.

I then need to set a variable of the @order of that WI element for that
<Board>.

If n Is Nothing Then
Dim varOrder = 1
Else
Dim varOrder = retrieved_order + 1....etc.

Any clues appreciated...sorry to be so stupid about this.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 11 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
> I'm using the following xpath (works in visualizer)

No it doesn't "work in visualiser" (in case you mean the XPath
Visualizer)!

The XPath Visualiser returns the following error message:

"Error No.:-2147467259
Error: Node test expected here.

//Station[@name="Station1"]/-->(<--WI[Boards/Board[@sn="583230"][@finish]])[last()]]/@order"
So what's so strange in this error message?
with a
SelectSingleNode("xpath") statement.

//Station[@name="Station1"]/(WI[Boards/Board[@sn="583230"][@finish]])[la
st()]]/@order


The error message points out explicitly what's illegal with the syntax
of the above XPath expression. The exact offending symbol is marked.

To understand why a bracket cannot be used in place of a node-test one
must have a minimal familiarity with XPath 1.0. This requires to read
a good introductory level book on XSLT/XPath (all good books about
XPath that I'm aware of usually cover XSLT too).
Another note is about the way you present your problem:

- You do not provide the source xml document on which the XPath
expression is to be evaluated.

- You do not explain what nodes you want to select.

Presenting a problem in this way makes it extremely difficult for
anyone to guess and help.

This is definitely not a good way to ask a question and not
surprisingly there would not be useful answers.

Also, if the question is so basic (e.g. not understanding a good error
message explaining an obvious syntax error), very few people would be
tempted to provide an answer for someone who has not "done their
homework" (e.g. didn't read even the simplest and most introductory
book on the subject).

Answers to random questions are not a substitute for systematic
learning, which is required in order to understand any subject.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Nov 11 '05 #2

P: n/a
Dimitre,

I've read SEVERAL books on the subject including Tennison and Kay.
However, it is a very different language than what I've been used to...I
may be a slow learner, but at least I continue to TRY.

My apologies on the () including in the xpath...I copied it manually and
they were not (obviously) in the xpath that worked in xpathvisualizer.
It highlighted the @order node I required.

I did not include xml simply because I thought the structure was defined
clearly enough in the xpath statement.

Perhaps I posted this question to the wrong group? I still need to know
how (in asp.net) to get a SelectSingleNode("xpath") to the point where
AFTER that statement I can set a variable on the "order" attribute of
the WI element. I am using the xpath WITHOUT the offending parens and
continue to get the error about the nodesset.

Would appreciate any other replies as I'm a bit stuck.

Sorry if I didn't phrase the question correctly.

Thanks,

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 11 '05 #3

P: n/a
> Perhaps I posted this question to the wrong group? I still need to know
how (in asp.net) to get a SelectSingleNode("xpath") to the point where
AFTER that statement I can set a variable on the "order" attribute of
the WI element. I am using the xpath WITHOUT the offending parens and
continue to get the error about the nodesset.

Would appreciate any other replies as I'm a bit stuck.

Sorry if I didn't phrase the question correctly.


Sorry, but you continue to follow the wrong path:

1. Where/what is the XPath expression?

2. Where/what is your xml document (the shortest possible) on which
the XPath expression in 1. is to be evaluated?

3. Where/what is your description in English of what you want to be
selected?

4. Where/what is your (I assume VB.Net) ASP code (shortest possible
-- just relevant to the problem)?
In case anyone of the above is not provided (and in your present
message you provide none of them), even people willing to help will
have only to guess.
On the other side, there are many, many examples in the newsgroups of
well-formulated questions, which get solutions in a straightforward
manner.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Nov 11 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.