Connecting Tech Pros Worldwide Forums | Help | Site Map

XPath query problem w-attributes

Dave Lech
Guest
 
Posts: n/a
#1: Nov 12 '05
In a C# app I have an XPath query where I am trying to return a single node
based on the value of 2 different attributes.
The xml looks something like this:

<TESTS>
<TEST SAMPLE_NUMBER="1" TEST_NUMBER="1"/>
<TEST SAMPLE_NUMBER="1" TEST_NUMBER="2"/>
<TEST SAMPLE_NUMBER="2" TEST_NUMBER="1"/>
<TEST SAMPLE_NUMBER="2" TEST_NUMBER="2"/>
</TESTS>


From the TESTS node I am calling the SelectSingleNode() method like this:

XmlNode testNode = testsNode.SelectSingleNode("TEST[@SAMPLE_NUMBER = 1 and
@TEST_NUMBER = 1]");

I keep getting an "Invalid token" exception. What is wrong?

Any help is greatly appreciated.

Dave Lech





Martin Honnen
Guest
 
Posts: n/a
#2: Nov 12 '05

re: XPath query problem w-attributes




Dave Lech wrote:
[color=blue]
> In a C# app I have an XPath query where I am trying to return a single node
> based on the value of 2 different attributes.
> The xml looks something like this:
>
> <TESTS>
> <TEST SAMPLE_NUMBER="1" TEST_NUMBER="1"/>
> <TEST SAMPLE_NUMBER="1" TEST_NUMBER="2"/>
> <TEST SAMPLE_NUMBER="2" TEST_NUMBER="1"/>
> <TEST SAMPLE_NUMBER="2" TEST_NUMBER="2"/>
> </TESTS>
>
>
> From the TESTS node I am calling the SelectSingleNode() method like this:
>
> XmlNode testNode = testsNode.SelectSingleNode("TEST[@SAMPLE_NUMBER = 1 and
> @TEST_NUMBER = 1]");
>
> I keep getting an "Invalid token" exception. What is wrong?[/color]

Does the C# compile?
If the exception occurs at runtime on which line does it occur, the
SelectSingleNode or earlier?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Closed Thread


Similar .NET Framework bytes