My question is somewhat related to the previous question in this
newsgroup:
http://groups.google.de/group/micros...58771b3b60cd47
I am having trouble unerstanding how to use XmlNode.SelectSingleNode
Method (String, XmlNamespaceManager) node when an xmlns Atrribute is
present. this is my xml file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="http://company.de/VCT9/Core/Configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://company.de/VCT9/Core/Configuration
config.xsd">
<logging>
<listeners>
<listener
name="myXMLListener"
outputFormat="XML"
targetType="File"
targetFileName="%source%_dd-MM-yy.log"
targeFileMaxSize=""
filterSources="AIS.*|SomeTarget"
filterEventTypes="All" />
<listener
name="myCSVListener"
outputFormat="CSV"
outputOptions="Callstack ThreadId"
targetFileName="dd-MM-yyyy.csv" />
</listeners>
</logging>
</configuration>
Now I am selecting the <listenersnode like this:
XmlDocument configurationDocument = new XmlDocument();
configurationDocument.Load(configFile);
XmlNamespaceManager manager = new
XmlNamespaceManager(configurationDocument.NameTabl e);
manager.AddNamespace("config",
"http://company.de/VCT9/Core/Configuration");
XmlNode listenersNode
= configurationDocument.SelectSingleNode
("//config:listeners",manager);
This works fine. There is only one problem, I seem to be forced to
hardcode the namespace:
manager.AddNamespace("config",
"http://company.de/VCT9/Core/Configuration");
I do not know the urn for the namespace
("http://company.de/VCT9/Core/Configuration") of the root node
<configurationat compiletime. It might change. How can I select the
<listenersnode without knowing the namespaceurn at compiletime.
While we are at it. Maybe it is possible to connect a xml-schema with a
xml file without having to specify a namespace
(xmlns="http://company.de/VCTC3/Core/Configuration") at all? If is how?