473,503 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

urgent help

Hi,

I have a document
<root>
<name>John</name>
</root>
and the xpath "//name" will return correct node by using
xmldoc.SelectSingleNode(xpath)

and if the document contains a default namespace
<root xmlns="mynamespace">
<name>John</name>
</root>
the xpath "//name" no longer returns the <name> node

Please help!!!

Thanks very much!
John

Nov 17 '05 #1
3 1278
hmm if i remember correctly, you need to qualify your xpath with the
namespace:

xpath = "mynamespace://name"

And you also might need to use an XML NamespaceManager in your app.

"John Lee" <jo***@newsgroup.nospam> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a document
<root>
<name>John</name>
</root>
and the xpath "//name" will return correct node by using
xmldoc.SelectSingleNode(xpath)

and if the document contains a default namespace
<root xmlns="mynamespace">
<name>John</name>
</root>
the xpath "//name" no longer returns the <name> node

Please help!!!

Thanks very much!
John

Nov 17 '05 #2
I could not make it work using nsmgr - please help with code, thanks!
John
"Michael C#" <ho***@boutdat.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
hmm if i remember correctly, you need to qualify your xpath with the
namespace:

xpath = "mynamespace://name"

And you also might need to use an XML NamespaceManager in your app.

"John Lee" <jo***@newsgroup.nospam> wrote in message
news:us**************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a document
<root>
<name>John</name>
</root>
and the xpath "//name" will return correct node by using
xmldoc.SelectSingleNode(xpath)

and if the document contains a default namespace
<root xmlns="mynamespace">
<name>John</name>
</root>
the xpath "//name" no longer returns the <name> node

Please help!!!

Thanks very much!
John


Nov 17 '05 #3
Hi John,

Here is a simple example that can make it work. HTH.

XmlDocument doc = new XmlDocument();
doc.LoadXml("<root xmlns=\"mynamespace\"><name>John</name></root>");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("v", "mynamespace");
XmlNode node = doc.SelectSingleNode("//v:name", nsmgr);

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #4

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

Similar topics

9
4280
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY (for days) and MMYYYY (for months). The target...
8
5208
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
2
1587
by: Dimitri | last post by:
PLEASE HELP,I HAVE A DATABSE WITH MULTIPLE RECORDS AS OUTLINED BELOW EMP NO LEVEL NEXTINCREASE WAGETYPE UNIT 1000 1 0 1000 1000 1 0 1002 ...
8
1807
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error for some of my web application users but not others??? Even though the application runs from a central webserver??? Thanks for...
16
2890
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
7
7224
by: zeyais | last post by:
Here is my HTML: <style> ..leftcolumn{float:left;width:300px;border: 1px solid #ccc} ..rtcolumn{float:left;width:600px;border: 1px solid #ccc} </style> <body> <div class="leftcolumn"...
33
3361
by: dembla | last post by:
Hey Frnds can anyone help me in this i need a program in 'c' PROGRAM to print NxN Matrix 9 1 8 1 2 3 2 7 3 as 4 5 6 6 4 5 7 8 9 in sorted form
8
2750
by: ginnisharma1 | last post by:
Hi All, I am very new to C language and I got really big assignment in my work.I am wondering if anyone can help me.........I need to port compiler from unix to windows and compiler is written...
17
2264
by: Saps | last post by:
Hi all. Can anyone help me here. I have loads of .sql files and i need a way to call these from my asp page so the user can run them from the browser. Meaning i have a page with a list of all...
3
6433
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
0
7207
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
7291
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
7357
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...
1
7012
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...
0
5598
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,...
0
4690
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...
0
3180
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...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
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 ...

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.