tags:

views:

115

answers:

1
var xmlDoc = new XmlDocument();
xmlDoc.Load("XMLFile1.xml");
XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
manager.AddNamespace("frbny", "urn:toto");
var curs = xmlDoc.SelectNodes("/frbny:DataSet/frbny:Series/frbny:Key/frbny:CURR");
var values = xmlDoc.SelectNodes("/frbny:DataSet/frbny:Series/frbny:Obs/frbny:OBS_VALUE");

Why this code does not work ? It throws with the first xmlDoc.SelectNodes, saying that he does not find the namespace manager or the XsltContext...

I've done the same thing as here : http://support.microsoft.com/kb/318545

+2  A: 

You're not passing in the namespace manager to the select nodes call, but you are using namespaces in the xpath.

var curs = xmlDoc.SelectNodes("/frbny:DataSet/frbny:Series/frbny:Key/frbny:CURR", manager);

Will prevent the exception.

Andrew Barrett
It's a shame thanks you...
Nicolas Dorier