I am trying to get an XML document to load so that I can pull information out of it when an aspx page loads and populate labels through out a page.
In the <pagename>.cs.aspx code behind file within the Page_Load function I have the following.
At this point the code initiates; however, it fails at the doc.LoadXML line. I have tried doc.Load and other path attempts with no avail. It jumps to the catch function and rightfully displays the an error has occured.
Could there be a problem in the XML file itself that is causing the error?
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Schema;
using System.IO;
public partial class obedience : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
XmlNode node = null;
try
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("http://www.site.com/XML/Classes.xml");
node = doc.SelectSingleNode("//class[./name/text()='classname']");
bodescription.Text = node.ChildNodes[1].InnerText;
}
catch (Exception ex)
{
bodescription.Text = "An Error Occured";
}
}
}