Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 11th, 2005, 10:50 PM
Kathy Burke
Guest
 
Posts: n/a
Default xpath again - not xslt ? but to select node in asp.net

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!
  #2  
Old November 11th, 2005, 10:50 PM
Dimitre Novatchev
Guest
 
Posts: n/a
Default Re: xpath again - not xslt ? but to select node in asp.net

> 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?
[color=blue]
> with a
> SelectSingleNode("xpath") statement.
>
> //Station[@name="Station1"]/(WI[Boards/Board[@sn="583230"][@finish]])[la
> st()]]/@order[/color]

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
  #3  
Old November 11th, 2005, 10:50 PM
Kathy Burke
Guest
 
Posts: n/a
Default Re: xpath again - not xslt ? but to select node in asp.net

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!
  #4  
Old November 11th, 2005, 10:50 PM
Dimitre Novatchev
Guest
 
Posts: n/a
Default Re: xpath again - not xslt ? but to select node in asp.net

> Perhaps I posted this question to the wrong group? I still need to know[color=blue]
> 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.[/color]

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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles