473,725 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("<p ath to above file>");
string xpath = "/Root/Category[@CategoryID='1']/Elements/Element";
XMLNodeset nodes = xmldoc.SelectNo des(xpath);
//nodes.Count = 3

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

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


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

Does this work:
XmlElement params =
xmldoc.SelectSi ngleNode("/Root/Category[@CategoryID='1']/Parameters") as
XmlElement;
params.SelectNo des("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("M sxml2.DOMDocume nt.4.0")
xmlDoc.async = false
xml_path = "onega.xml"
xmlDoc.load xml_path
xmlDoc.setPrope rty "SelectionLangu age", "XPath"
xpath_str = "/Root/Category[@CategoryID='1']/Parameters/Parameter"
set objNodeList = xmlDoc.document Element.selectN odes(xpath_str)
WScript.Echo CStr(objNodeLis t.length)

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:em******** ********@TK2MSF TNGP12.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("<p ath to above file>");
string xpath = "/Root/Category[@CategoryID='1']/Elements/Element";
XMLNodeset nodes = xmldoc.SelectNo des(xpath);
//nodes.Count = 3

xpath = "/Root/Category[@CategoryID='1']/Parameters/Parameter";
nodes = xmldoc.SelectNo des(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
3066
by: Mysooru | last post by:
Hi All, One of the ATL class..... template <class Base> class CComObject : public Base { public: typedef Base _BaseClass;
3
2029
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
2470
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 the spec (10.1.6) the activation-object already contains the the parameters-object when the variables are instantiated (10.1.3). The question is now: does a parameter "parameters" overwrite the "parameters"-object or not? All three implementations...
4
4035
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' The error shows compiler is quite confused - x is not a template parameter at all. I have found two workarounds, but still I think the code should compile.
1
2691
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 all? - if not, what work-a-round is there? I have no issues passing "string" parameters successfully to other methods in the same "middle-tier" - i.e., C# - object... It just seems to be the "ArrayList" parameter that is at issue.
9
3009
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 field. I do this by adding the mail to the CC field via a header. However, by the time I get to the point of sending the mail, my recipient list is now empty, so I get the "SMTPRecipientsRefused" error.
2
1456
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 = MyTestFunction(myObject.Parameter)
4
3294
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 "end" is obvious. But not so for "start".
2
3045
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 for the information i get a STATUS_INFO_LENGTH_MISMATCH which is -1073741820 in number, this is ok, but why does the function not store the required
0
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9174
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8096
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.