473,394 Members | 1,735 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,394 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 2723
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.