1

Can somebody explain me please why this is not working?

XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("Bing2_ss.xml");

                    //Instantiate an XmlNamespaceManager object. 
                    XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(xmlDoc.NameTable);
                    //Add the namespaces used in feed to the XmlNamespaceManager.
                    //xmlnsManager.AddNamespace("base", "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Composite");
                    xmlnsManager.AddNamespace("m",   "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
                    xmlnsManager.AddNamespace("d",   "http://schemas.microsoft.com/ado/2007/08/dataservices/");
                    xmlnsManager.AddNamespace(String.Empty, "http://www.w3.org/2005/Atom");

                    XmlNodeList nodeList;
                    XmlElement root = xmlDoc.DocumentElement;
                    nodeList = root.SelectNodes("//m:properties/d:WebTotal", xmlnsManager);
                    foreach (XmlNode nd in nodeList)
                    {
                        System.Console.WriteLine(nd.InnerText);
                    }

This is the original xml: http://gezond-afslanken.info/bing2_ss.xml

1
  • Do you get an error message at all? Commented Aug 15, 2012 at 16:09

1 Answer 1

2

You have an extra trailing slash on one of your namespaces. Try

xmlnsManager.AddNamespace("d","http://schemas.microsoft.com/ado/2007/08/dataservices");
Sign up to request clarification or add additional context in comments.

1 Comment

Unbelievable...I copied it from the xml document it self. That stupid slash took me bussy for 3 hours! Tnx mate!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.