TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sandra abo
NA
6
909
Selecting Nodes in xmldocument
Nov 5 2016 4:05 PM
I am trying to call webservice and when hit search button to return value, the page throw error. I'm trying to parse data from calling API using xpath;
Code:
protected
string
getattributevalue(
string
id, XmlDocument doc)
{
// Load the document and set the root element.
XmlNode root = doc.DocumentElement;
// Add the namespace.
XmlNamespaceManager nsmgr =
new
XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace(
"go"
,
"http://b.myserver.com/student/sign.xsd"
);
String result;
// Select and display the first node in which the author's
try
{
XmlNodeList nodelist = root.SelectNodes(
"//signup"
, nsmgr);
// Console.WriteLine(node.InnerXml);
result = nodelist.Count.ToString();
}
catch
(XPathException ex)
{
Console.Write(ex.ToString());
result =
"Error: "
+ ex.ToString();
}
catch
(NullReferenceException ex)
{
Console.Write(ex.ToString());
result =
"Error: "
+ ex.ToString();
}
return
result;
}
Error: System.NullReferenceException: Object reference not set to an instance of an object. at WebReg._Default.getattributevalue(String id, XmlDocument doc) in Default.aspx.cs:line 55 XmlNodeList nodelist = root.SelectNodes("//signup", nsmgr);
Reply
Answers (
2
)
How to pass user credentials in SOAP header.
How WCF hosted on IIS?