473,769 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[Help]It returns 0 when using C# to process XML.

Here is the XML in a file:
<?xml version='1.0' encoding='utf-8' ?>
<bkxml version='1.0' xmlns='http://www.w3.org/2003/03/bkxml'>
<model>
<data name="angle" expr="100"></data>
<data name="sample" expr="200"></data>
</model>
</bkxml>
I use
XmlDocument.Doc umentElement.Se lectNode("/bkxml/model/data").Count,bu t
it returns 0. It will work once xmlns is omitted. However I have
defined Bkxml.xsd well, and validation is ok.

Who have experienced the same problem? Could you explain the reason?

Thank you!

Sand

Aug 29 '06 #1
2 1461
wi******@gmail. com wrote:
Here is the XML in a file:
<?xml version='1.0' encoding='utf-8' ?>
<bkxml version='1.0' xmlns='http://www.w3.org/2003/03/bkxml'>
<model>
<data name="angle" expr="100"></data>
<data name="sample" expr="200"></data>
</model>
</bkxml>
I use
XmlDocument.Doc umentElement.Se lectNode("/bkxml/model/data").Count,bu t
it returns 0. It will work once xmlns is omitted. However I have
defined Bkxml.xsd well, and validation is ok.

Who have experienced the same problem? Could you explain the reason?
Namespace issue. You select nodes from the null namespace. But the
elements in your XML are in the 'http://www.w3.org/2003/03/bkxml'
namespace. Read up about mapping prefixes to namespace URIs and then use
a prefix in the XPath.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Aug 29 '06 #2
wi******@gmail. com wrote:
XmlDocument.Doc umentElement.Se lectNode("/bkxml/model/data").Count,bu t
it returns 0. It will work once xmlns is omitted.
XPaths are namespace-aware. You must use a prefix in your XPath and
provide the XPath evaluator with context information that binds that
prefix to the appropriate namespace, even if the default-namespace
syntax was used in the document. The only alternative is the ugly one of
writing XPaths with wildcards and then using predicates to test their
names -- which, among its other flaws, runs less efficiently in some
processors.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Aug 29 '06 #3

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

Similar topics

9
3394
by: J. Campbell | last post by:
I'm comfortable with arrays from previous programming, and understand the advantages of c++ vectors...I just don't understand how to use them :~( Can you help me to use a vector<string> in the following compilable example instead of the string* array? Thanks, Joe #include <iostream>
1
1611
by: Alex | last post by:
I have a form that when the user click's the "What's This" question mark and the form's section, a pop-up help screen appears. I would like to automatically display this pop-up help context when the form is opened. Any suggestions? Thanks, Alex
0
895
by: Daniel | last post by:
hi, I want to find all the objects in my ascx embeded in another ascx of aspx. How can i use JavaScript loop through all the objects in order to find the name i want. For instance, using document.all.dropdownlist1.value (but there is no such object, although i have this in my ascx). I appreicate your help.
8
2395
by: trialproduct2004 | last post by:
Hi all. I am having application in vb.net. I am having module and one form. From module i am opening form. On main itself i am checking whether another instance of application is running or not. I am also providing faclity of minimizing application to system tray. What i want is after clicking on exe of my application, it should check whether my app is already running or not. If yes i don;t want to create
2
298
by: shivaranjani.s.adimulam | last post by:
Hi, I have a .NET application where I want to restore the previos application if it is already running and in minimized state. The code I added is working fine in the case if the previous application is only minimized but if it is minimized in to the system tray then the code fails.
4
6738
by: Charles | last post by:
I am doing a Digital signal processing project using VB.net and need advance maths function and also signal processing function such as fast fourier transform. Can anyone advice me on how do I get a FFT function? Thanks for any reply.
1
1113
by: Bishman | last post by:
Hi, I have an odd problem that someone else may have come accross. VS2005 Pro. Fulll MSDN Installed. Search set up to only go local (Not online) On Friday I noticed that I was getting no results back from my searches. I investigated today (Monday) and have determined that when signed on as a local Administrator I get the expected search results. When signed onto the
0
1321
by: Deven Oza | last post by:
please help me to solve the query. (Using Case statements) Write PL/SQL code such that: the user will input a letter (A, B, C); the letter will refer to a case statement that will ask for further information and will give output accordingly. Note you might use If statements embedded in the Case statements. Choice Input Output A Ask for date of birth Your age is ( number indicating (age...
2
1267
by: CharlesHawk | last post by:
HI i am working on a Project where i have to send a string using Sessions to the next page this is working gud for now But i can convert session to a string the .ToString(); and the Convert.ToString(.....); is not workin I am using Web Matrix . Please Help me ASAP. tanx
0
9589
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
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10045
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
9994
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
9863
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
8870
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
7408
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
6673
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
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...

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.