473,804 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

namespacemanage r and selectsinglenod e

Hi,

I am using xmldocument.sel ectsinglenode to query an xml document.
This works perfectly when the document to be queried has no namespace,
however as some as i put a namespace in then null is returned from
selectsinglenod e.

I think I am not creating the namespace manager correctly.

I have created a very small sample piece of code (see below) that
demonstates the problem.

If anybody could point out my mistake based on the code below then I would
be extremly greatful.

many thanks in advance.

cheers

martin.

//paste the code below into the main function of a console app.

XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml( @"<?xml version=""1.0"" ?><Addresses
xmlns:xsd=""htt p://www.w3.org/2001/XMLSchema""
xmlns:xsi=""htt p://www.w3.org/2001/XMLSchema-instance""
xmlns=""http://mydomain.com/TimeSeriesSchem a.xsd""><Addres s>38 some
road</Address></Addresses>");
//comment the line above and uncomment the line below and everything
works fine.
//xmldoc.LoadXml( @"<?xml version=""1.0"" ?><Addresses><A ddress>38 some
road</Address></Addresses>");
XmlNamespaceMan ager namespaceManage r = new
XmlNamespaceMan ager(xmldoc.Nam eTable);
namespaceManage r.AddNamespace( "","http://www.w3.org/2001/XMLSchema");

Console.WriteLi ne(xmldoc.Selec tSingleNode("Ad dresses/Address").Outer Xml.ToSt
ring() , namespaceManage r);
//xmldoc.Save(Con sole.Out);
return;
Nov 19 '05 #1
0 1224

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

Similar topics

3
6063
by: John R. | last post by:
I have an application written in C# and i am using MS XML DOM! I have a document with the following structure (only the <DicEntry> - Elements are important): <NewDataSet xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance">
2
9870
by: Edward Yang | last post by:
My XML document has a default namespace specified by xmlns="some_url". Here it is: <?xml version="1.0" encoding="utf-8" ?> <ssmproject name="sample" server="sql" xmlns="mailto:neo_in_matrix@msn.com?subject=ssmprjx" > <pr>
7
18563
by: Jason | last post by:
Hi I have an XML file i need to load and read the contents. Here is the top part of the xml file. <Research xsi:schemaLocation="http://www.rixml.org/2002/6/RIXML http://GreenJAR/DAVCatalog/Dashboards/GreenJAR/Documents/Schemas/RiXML2.xsd" researchID="" createDateTime="2003-07-10T00:00:00" language="eng" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.rixml.org/2002/6/RIXML">
2
2533
by: Chris | last post by:
Hi, I'm trying to extract data from objects that contain xml that fits a third party schema with it's own root namespace. I've added a namespace manager that seemed to work most of the time but I never fully understood why. I've now hit another problem. It might be code blindness but I can't see why it doesn't work. I am trying to select a node using XPath from an XmlElement
7
3829
by: Sashi | last post by:
Two questions: (1) I can pull the text of an XML element as a string just fine using code as such: strSomeString = myXmlDoc.SelectSingleNode("/Element1/Element2/Element3", myXmlNSMgr).InnerText;
19
16225
by: David Thielen | last post by:
Hi; If there are no namespaces this works fine for me. But if the xml has namespaces, then I get either no node back or an exception. Here is the sample xml: <root xmlns="http://www.test.org" xmlns:sns="http://www.test.org/sub" xmlns:mns="http://www.test.org/mini"> <data>
4
4417
by: Vishy | last post by:
Hi I'm trying to read xml file with namespacemanager; it seems that it adds up a namespace if there is none; How can avoid this? so <ID>00589</ID> becomes <Id xmlns=\"x-schema:#Schema1\">00589</Id> Thanks
1
5072
by: Bruce Sandeman | last post by:
Hi, Is anyone able to help me? I have the following code and when I try to create an XPathNavigator object it keeps returning null. any cunning ideas? private void loadXMLDoc(String xml) { xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); namespaceManager = new
0
1810
by: compumate99 | last post by:
I am trying to parse the xml document using selectsinglenode method. I am doing this using Visual Foxpro >>> loResultXml = CreateObject("Microsoft.XMLDOM") With loResultXml .Async = .F. .Load(pcXmlFile) oPackage = .documentElement.SelectSingleNode("//Package")
0
10599
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10347
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
9173
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
7635
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
6863
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
5531
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...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
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
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.