Click here to Skip to main content
15,910,123 members
Home / Discussions / C#
   

C#

 
AnswerRe: Console to GUI Change: RegEx Error Pin
DigitalKing15-Feb-06 13:40
DigitalKing15-Feb-06 13:40 
GeneralRe: Console to GUI Change: RegEx Error Pin
Expert Coming15-Feb-06 14:05
Expert Coming15-Feb-06 14:05 
QuestionDirectDraw surfaces without DirectX Pin
Chris Boden14-Feb-06 16:42
Chris Boden14-Feb-06 16:42 
AnswerRe: DirectDraw surfaces without DirectX Pin
CWIZO14-Feb-06 21:02
CWIZO14-Feb-06 21:02 
QuestionProblem With ToolBars Pin
Tyrus18214-Feb-06 16:26
Tyrus18214-Feb-06 16:26 
AnswerRe: Problem With ToolBars Pin
Joshua Quick14-Feb-06 17:34
Joshua Quick14-Feb-06 17:34 
QuestionTest a DIB for percentage of black pixels Pin
davidhart14-Feb-06 15:06
davidhart14-Feb-06 15:06 
Questionxml doc consumption with multiple namespaces -- corrected Pin
spin vector14-Feb-06 12:06
spin vector14-Feb-06 12:06 
Hi,

I've built an xml schema hierarchy where, for instance, {path, file} is a schema type and subsequently {params_1, params_2, ...} each import a {path, file} type. I include code below.

My question is this: How to resolve use of namespaces and hierarchical schema design with C# xml consumption.

From C# I do this:

reader = new XmlTextReader(config_filename);
xmldoc = new XmlDocument();
xmldoc.Load(reader);

Then this:

XmlNode n = doc.SelectSingleNode( "session/gateway/file" )

This instruction returns 'null'. I believe its because the xml doc reads <ns1:file> rather than <file>. However, I want <ns1:file> (or whatever namespace) because I want to have reusable schema patterns.

(Note doc.SelectSingleNode( "session/gateway" ) and ...( "session" ) do work.)

The reason I'm doing SelectSingleNode( x ) is to populate a HashTable with specific values possibly available in the xml.

Finally, here's a snippet of my xml doc. Thanks in advance.

<?xml version="1.0" encoding="UTF-8"?>
<session xmlns:ns1="foo" xmlns:ns2="bar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="baz.xsd">
<gateway>
<ns1:path>(/ns1:path>
<ns1:file>"gateway.xml"</ns1:file>
</gateway>
<strats>
<ns1:path></ns1:path>
<ns1:file>"strats.xml"</ns1:file>
</strats>
<log>
<ns1:path></ns1:path>
<ns1:file>"session.log"</ns1:file>
</log>
</session>





-- modified at 7:17 Wednesday 15th February, 2006
AnswerRe: xml doc consumption with multiple namespaces Pin
Curtis Schlak.14-Feb-06 15:23
Curtis Schlak.14-Feb-06 15:23 
GeneralRe: xml doc consumption with multiple namespaces Pin
spin vector15-Feb-06 1:24
spin vector15-Feb-06 1:24 
GeneralRe: xml doc consumption with multiple namespaces Pin
Curtis Schlak.15-Feb-06 3:33
Curtis Schlak.15-Feb-06 3:33 
GeneralRe: xml doc consumption with multiple namespaces Pin
spin vector15-Feb-06 10:36
spin vector15-Feb-06 10:36 
GeneralRe: xml doc consumption with multiple namespaces Pin
Curtis Schlak.15-Feb-06 15:23
Curtis Schlak.15-Feb-06 15:23 
Questionicon Pin
mostafa_h14-Feb-06 11:28
mostafa_h14-Feb-06 11:28 
AnswerRe: icon Pin
Andy Moore14-Feb-06 11:32
Andy Moore14-Feb-06 11:32 
GeneralRe: icon Pin
Expert Coming14-Feb-06 17:40
Expert Coming14-Feb-06 17:40 
GeneralRe: icon Pin
Andy Moore15-Feb-06 3:02
Andy Moore15-Feb-06 3:02 
GeneralRe: icon Pin
mostafa_h15-Feb-06 9:37
mostafa_h15-Feb-06 9:37 
QuestionPDF Pin
tabrez_0114-Feb-06 10:41
tabrez_0114-Feb-06 10:41 
QuestionArranging Toolbar window items in IE to a single row .. Pin
sreejnarayan14-Feb-06 10:37
sreejnarayan14-Feb-06 10:37 
QuestionUsing Remoting For Whole Application Pin
mk2014-Feb-06 10:00
mk2014-Feb-06 10:00 
AnswerRe: Using Remoting For Whole Application Pin
malharone14-Feb-06 10:24
malharone14-Feb-06 10:24 
QuestionOverriding DataGridViewColumnHeaderCell Pin
Wjousts14-Feb-06 9:48
Wjousts14-Feb-06 9:48 
QuestionQuestion on reflection Pin
malharone14-Feb-06 9:06
malharone14-Feb-06 9:06 
AnswerRe: Question on reflection Pin
leppie14-Feb-06 10:01
leppie14-Feb-06 10:01 

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.