473,416 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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!
Nov 11 '05 #1
3 4523
> 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
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
1
by: inquirydog | last post by:
Can anyone explain to me why the following XQuery expression (a simple xpath expression) returns a different result than the same expression in xslt? document("document.xml")//a/@b For the...
2
by: nkunapa | last post by:
Hi: Is there a way in XPATH to find the nearest node of the node in context with a certain attribute value. Here is my problem. I have the following XML and I am trying to add all the nodes with...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
14
by: Mat| | last post by:
Hello :-) I am learning XPath, and I am trying to get child nodes of a node whose names do *not* match a given string, e.g : <dummy> <example> <title>Example 1</title> <body>this is an...
2
by: Pandikkannan | last post by:
I am new to XSLT. The requirement i have is to convert an XML to another XML format. My source XML looks something like: <QryLMLCheck>...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.