Hi Kavita, I think XML is well formatted but YES, namesapces are missing there. Hence, we need to include namesapces dynamically over there. After that we can process.
Correct Me, If I am Wrong!!!
Please "Mark As Answer;", if this Post helps you.
Visit My Blog
kuber.manral
Contributor
3051 Points
714 Posts
Re: xml with namespace manager - cant find node value?
Mar 01, 2012 10:04 AM|LINK
Hi, As I believe Thread poster wants to share his solution wich was initially raised by him here :
http://forums.asp.net/t/1772611.aspx/2/10?xml+selecting+single+node
Dut to some techincal issues, he could not post that there. So started a new thread to share his solution here at forum. ;)
Hi Jbear, please marked your thread As resolved As you already posted solution.
For a reference again, i am providing relevant code again here:
System.Net.WebRequest request = System.Net.WebRequest.Create(uri); System.Net.WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader sr = new StreamReader(stream); string xmlcontents = sr.ReadToEnd(); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(xmlcontents); XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable); xnm.AddNamespace("web", "http://www.w3.org/2005/Atom"); totalresults.Text = "Results: " + doc.SelectSingleNode("SearchResponse/web:Web/web:Total", xnm).InnerText;Hi Kavita, I think XML is well formatted but YES, namesapces are missing there. Hence, we need to include namesapces dynamically over there. After that we can process.
Correct Me, If I am Wrong!!!
Visit My Blog