Click here to Skip to main content
15,911,786 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: SelectSingleNode Not Getting Node Pin
Ed.Poore29-Oct-07 13:42
Ed.Poore29-Oct-07 13:42 
GeneralRe: SelectSingleNode Not Getting Node Pin
#realJSOP29-Oct-07 23:20
professional#realJSOP29-Oct-07 23:20 
GeneralRe: SelectSingleNode Not Getting Node Pin
Ed.Poore30-Oct-07 0:22
Ed.Poore30-Oct-07 0:22 
GeneralRe: SelectSingleNode Not Getting Node Pin
#realJSOP30-Oct-07 2:42
professional#realJSOP30-Oct-07 2:42 
GeneralRe: SelectSingleNode Not Getting Node Pin
Ed.Poore30-Oct-07 3:06
Ed.Poore30-Oct-07 3:06 
GeneralRe: SelectSingleNode Not Getting Node Pin
#realJSOP30-Oct-07 3:19
professional#realJSOP30-Oct-07 3:19 
GeneralRe: SelectSingleNode Not Getting Node [modified] Pin
#realJSOP30-Oct-07 3:05
professional#realJSOP30-Oct-07 3:05 
GeneralRe: SelectSingleNode Not Getting Node Pin
Ed.Poore30-Oct-07 4:17
Ed.Poore30-Oct-07 4:17 
Ok the problem seems to be that .NET 2.0 supports XPath 1.0 and XPath 1.0 does not support default namespaces. To get around this you can do the following (for some reason Confused | :confused: ):

Sample Xml File
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <connectionStrings>
		<add name="SQL" connectionString="SQL" />
	</connectionStrings>
</configuration>


Sample code:
using System;
using System.Xml;

namespace ConsoleApplication1
{
	class Program
	{
		static void Main(string[] args)
		{
			XmlDocument dom = new XmlDocument();
			dom.Load("Web.config");

			XmlNamespaceManager manager = new XmlNamespaceManager(dom.NameTable);
			manager.AddNamespace("default", "http://schemas.microsoft.com/.NetConfiguration/v2.0");

			XmlNode node = dom.DocumentElement.SelectSingleNode("default:connectionStrings", manager);

			if (node == null)
				Console.WriteLine("(null)");
			else
				Console.WriteLine(node.OuterXml);
		}
	}
}


Notice where I added the default namespace with a assigned name default, the documentation says that the default namespace should be string.Empty but this does not work, if you give it a namespace then it does.

Hopefully it'll support XPath 2.0 at some point.


Question.NET on MAC OS Pin
Fayu29-Oct-07 10:23
Fayu29-Oct-07 10:23 
AnswerRe: .NET on MAC OS Pin
#realJSOP29-Oct-07 12:23
professional#realJSOP29-Oct-07 12:23 
AnswerRe: .NET on MAC OS Pin
Ed.Poore29-Oct-07 13:27
Ed.Poore29-Oct-07 13:27 
AnswerRe: .NET on MAC OS Pin
Pete O'Hanlon30-Oct-07 2:21
mvePete O'Hanlon30-Oct-07 2:21 
QuestionI need help! Threading [modified] Pin
tim63729-Oct-07 9:27
tim63729-Oct-07 9:27 
AnswerRe: I need help! Threading Pin
Luc Pattyn29-Oct-07 9:48
sitebuilderLuc Pattyn29-Oct-07 9:48 
GeneralRe: I need help! Threading Pin
Paul Conrad29-Oct-07 17:33
professionalPaul Conrad29-Oct-07 17:33 
GeneralRe: I need help! Threading Pin
tim63730-Oct-07 2:32
tim63730-Oct-07 2:32 
AnswerRe: I need help! Threading Pin
ganesh197530-Oct-07 3:04
ganesh197530-Oct-07 3:04 
GeneralRe: I need help! Threading Pin
tim63730-Oct-07 4:25
tim63730-Oct-07 4:25 
QuestionRunning Managed Code Pin
CodeWolf)29-Oct-07 4:43
CodeWolf)29-Oct-07 4:43 
QuestionRe: Running Managed Code Pin
TJoe29-Oct-07 5:30
TJoe29-Oct-07 5:30 
AnswerRe: Running Managed Code Pin
CodeWolf)29-Oct-07 5:34
CodeWolf)29-Oct-07 5:34 
QuestionRe: Running Managed Code Pin
TJoe29-Oct-07 6:24
TJoe29-Oct-07 6:24 
GeneralRe: Running Managed Code Pin
Mike Dimmick29-Oct-07 12:51
Mike Dimmick29-Oct-07 12:51 
GeneralRe: Running Managed Code Pin
CodeWolf)30-Oct-07 3:46
CodeWolf)30-Oct-07 3:46 
GeneralRe: Running Managed Code Pin
CodeWolf)30-Oct-07 3:56
CodeWolf)30-Oct-07 3:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.