I am attempting to parse through an XML document using the XmlDocument
object. I keep getting a NullReferenceException. I have even tried using
the fully qualified name, but with no luck. Here is the code:
private void Page_Load(object sender, System.EventArgs e)
{
StringBuilder sb = new StringBuilder();
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load(Server.MapPath("lib/schoolAnnouncements.xml"));
XmlNode nd;
nd = xd.FirstChild["counties"];
foreach(System.Xml.XmlNode n in nd.ChildNodes)
{
if(n.Name=="county")
sb.Append(String.Format("{0}<br>",n.InnerText));
}
elems=sb.ToString();
}
Any suggestions?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!