473,396 Members | 1,784 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,396 software developers and data experts.

Selecting a namespace-prefixed node

Dag
Hi

I am pretty much an xml beginner; hopefully someone can easily answer this one... I want to select a node representing a worksheet in an xml document for the Office Web Components spreadsheet. The file uses xml namespaces, of which I know very little. But it does seem clear that I can't select the <ss:Worksheet> element by name only; the xpath "//Worksheet" does not match any nodes

Extract from the file, in case this is needed to come up with the solution

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"><!-- ... there's more, but I can't imagine we need it here --><!-- Below: what I want to select --><ss:Worksheet ss:Name="sheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"></ss:Worksheet></Workbook

Help greatly appreciated!
Nov 12 '05 #1
2 1546
Dag
Hi again,

I figured out a way. Just in case anyone else is wondering too, using the xpath //*[local-name()='ss:Worksheet'] is sufficient in my case. (However, I've just learned that the same namespace prefix can have different meanings in the same document; it is defined only for a subtree. Thus, in general, selecting nodes by means of the local-name() function could lead to selecting nodes that refer to different namespaces and have different meanings.)

Happy coding!

Nov 12 '05 #2
Dag wrote:
I figured out a way. Just in case anyone else is wondering too, using
the xpath //*[local-name()='ss:Worksheet'] is sufficient in my case.

Hmmm, actually it shouldn't work. local-name() function returns local
part of the name - "Worksheet". name() function returns local name along
with namespace prefix - "ss:Worksheet". //*[local-name()='Worksheet']
should work. But it's namespace unaware query.

Instead use overloaded SelectNodes method, which accepts
XmlNamespaceManager, see
http://msdn.microsoft.com/library/de...nodestopic.asp
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #3

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

Similar topics

12
by: mpinsley | last post by:
We are a software company that provides Inventory & Procurement mangement to the hospitality industry. For the past twenty years we have been using Progress Software as both the development...
3
by: Simon G Best | last post by:
Hello! The C++ standard library provides facilities for finding out the sizes (and other such stuff) of numeric types (::std::numeric_limits<>, for example). What I would like to do is to...
1
by: Simon Leonard | last post by:
I'm developing an API that I want be as user friendly as possible. My problem is that there are functions that can take many optional parameters (of various type) and I want to be able to specify...
2
by: kj | last post by:
Suppose I have some XML document that contains tags of the form <... xmlns:foo="http://www.bar.org/foo"> <... xmlns:foo="baz"> <... xmlns:frobozz="http://www.bar.org/foo"> What's the...
4
by: Dave | last post by:
Hello NG, In a thread I had started a long time ago, the conclusion had been reached that there is no good way to select between calling const vs non-const methods of the same name. (Of course,...
13
by: Tony | last post by:
Hi everyone, I am new to javascript (and new to programming). I want to have to drop down menus. One will ask use to select from one of the 50 states. The second one will be ask user to select a...
12
by: Lawrence Oluyede | last post by:
I've some problems with filtering out a specific element by the following xml snippet (is part of a bigger xml document): <entry> <link...
2
by: Sam74 | last post by:
Hi, I'm writing a program with Microsoft Visual C# .net version 2002 the program has 4 Forms and all the database components (DataSet, OleDbDataAdapter, OleDbConnection) are in form4 as I've got...
1
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
21
tsubasa
by: tsubasa | last post by:
I am working on a wish list where users add products to their list for future purhcases. I am using a GridView to display the records by users after they have login to the shopping cart. How can I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.