472,785 Members | 1,221 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

xpath fails : "Parameter" have special meaning ?

Is there something special in XML about the name "Parameter" ... I am not
able to XPATH query for nodes named "Parameter"

<Root>
<Category CategoryID="1">
<Elements>
<Element ElementID="1"></Element>
<Element ElementID="2"></Element>
<Element ElementID="3"></Element>
</Elements>
<Parameters>
<Parameter ParameterID="1"></Parameter>
<Parameter ParameterID="2"></Parameter>
<Parameter ParameterID="3"></Parameter>
</Parameters>
</Category>
<Category CategoryID="2">
</Category>
</Root>
XMLDocument xmldoc = New XMLDocument;
xmldoc.Load("<path to above file>");
string xpath = "/Root/Category[@CategoryID='1']/Elements/Element";
XMLNodeset nodes = xmldoc.SelectNodes(xpath);
//nodes.Count = 3

xpath = "/Root/Category[@CategoryID='1']/Parameters/Parameter";
nodes = xmldoc.SelectNodes(xpath);
//nodes.Count = 0
Nov 12 '05 #1
2 2682
Hello!
XMLDocument xmldoc = New XMLDocument;
xmldoc.Load("<path to above file>");
string xpath = "/Root/Category[@CategoryID='1']/Elements/Element";
XMLNodeset nodes = xmldoc.SelectNodes(xpath);
//nodes.Count = 3

xpath = "/Root/Category[@CategoryID='1']/Parameters/Parameter";
nodes = xmldoc.SelectNodes(xpath);
//nodes.Count = 0


Is this really your code? Maybe you have a typo in the original?

Does this work:
XmlElement params =
xmldoc.SelectSingleNode("/Root/Category[@CategoryID='1']/Parameters") as
XmlElement;
params.SelectNodes("Parameter").Count...

--
Pascal Schmitt
Nov 12 '05 #2
The following vbscript can get correct result, maybe you need to double
check your code.

Set xmlDoc = CreateObject("Msxml2.DOMDocument.4.0")
xmlDoc.async = false
xml_path = "onega.xml"
xmlDoc.load xml_path
xmlDoc.setProperty "SelectionLanguage", "XPath"
xpath_str = "/Root/Category[@CategoryID='1']/Parameters/Parameter"
set objNodeList = xmlDoc.documentElement.selectNodes(xpath_str)
WScript.Echo CStr(objNodeList.length)

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:em****************@TK2MSFTNGP12.phx.gbl...
Is there something special in XML about the name "Parameter" ... I am not
able to XPATH query for nodes named "Parameter"

<Root>
<Category CategoryID="1">
<Elements>
<Element ElementID="1"></Element>
<Element ElementID="2"></Element>
<Element ElementID="3"></Element>
</Elements>
<Parameters>
<Parameter ParameterID="1"></Parameter>
<Parameter ParameterID="2"></Parameter>
<Parameter ParameterID="3"></Parameter>
</Parameters>
</Category>
<Category CategoryID="2">
</Category>
</Root>
XMLDocument xmldoc = New XMLDocument;
xmldoc.Load("<path to above file>");
string xpath = "/Root/Category[@CategoryID='1']/Elements/Element";
XMLNodeset nodes = xmldoc.SelectNodes(xpath);
//nodes.Count = 3

xpath = "/Root/Category[@CategoryID='1']/Parameters/Parameter";
nodes = xmldoc.SelectNodes(xpath);
//nodes.Count = 0

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mysooru | last post by:
Hi All, One of the ATL class..... template <class Base> class CComObject : public Base { public: typedef Base _BaseClass;
3
by: Ian Lazarus | last post by:
// why is the error message being generated? // Microsoft Visual C/C++ 5.0 class Bar { public: void Log(const char* p){ } }; class Foo : public Bar
11
by: Florian Loitsch | last post by:
I'm currently writing a JS->Scheme compiler (which, using Bigloo, automatically yields a JS->C, JS->JVM, JS->.NET compiler), and have a question concerning the function-parameters: According to...
4
by: Ondrej Spanel | last post by:
The code below does not compile with .NET 2003, I get folowing error: w:\c\Pokusy\delegTemplArg\delegTemplArg.cpp(11) : error C2993: 'float' : illegal type for non-type template parameter 'x' ...
1
by: sd | last post by:
QUESTION: How can my ASP page - which uses language="VBScript" - pass a "System.Collections.ArrayList" object - as a parameter - to a C# method in the middle-tier ??? ----- Is it possible at...
9
by: EdWhyatt | last post by:
Hi all, I have searched the group with no answer to this particular problem. In my sendmail program, I would like to have the ability to send a mail message with no-one email address in the To...
2
by: Nemisis | last post by:
Hi, Is it possible to pass in an object and parameter into a function and return it as a string. i.e. To make a call to the function i would put the following Dim str as String =...
4
by: =?utf-8?B?Qm9yaXMgRHXFoWVr?= | last post by:
Hello, what is the use-case of parameter "start" in string's "endswith" method? Consider the following minimal example: a = "testing" suffix="ing" a.endswith(suffix, 2) Significance of...
2
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, the topic says all. I use this code from C# to call the NtQuerySystemInformation. When i call NtQuerySystemInformation the first time with zero buffer length to get the buffer size needed...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.