Troubling loading an XML file

Discussion in 'ASP.NET / ASP.NET Core' started by looseEnds, Jun 15, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am recieving the following error message:

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    The underlying connection was closed: The remote name could not be resolved.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.WebException: The underlying connection was closed: The remote name could not be resolved.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [WebException: The underlying connection was closed: The remote name could not be resolved.]
    System.Net.HttpWebRequest.CheckFinalStatus() +673
    System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +140
    System.Net.HttpWebRequest.GetResponse() +147
    System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials) +65
    System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +94
    System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +55
    System.Xml.XmlTextReader.CreateScanner() +384
    System.Xml.XmlTextReader.Init() +23
    System.Xml.XmlTextReader.Read() +530
    System.Xml.XmlValidatingReader.ReadWithCollectTextToken() +146
    System.Xml.XmlValidatingReader.Read() +26
    System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +80
    System.Xml.XmlDocument.Load(XmlReader reader) +72
    System.Xml.XmlDocument.Load(String filename) +78
    _2lalaland.hangman.Page_Load(Object sender, EventArgs e)
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +35
    System.Web.UI.Page.ProcessRequestMain() +731

    I have been assuming that the path to my XML file is incorrect. Here is the snippet of code that loads the XML file with the path I use on my localhost:

    Dim xmlDoc As XmlDocument = New XmlDocument()
    Dim xnlList As XmlNodeList
    xmlDoc.PreserveWhitespace = True
    xmlDoc.Load("D://IIS/2lalaland/games/Hangman/Wordlist.xml")
    xnlList = xmlDoc.SelectNodes("//NewWord")


    I have tried the following path references in the xmlDoc.Load() statement and nothing has worked:

    "\\xxxx\htdocs\games\Hangman\WordList.xml"
    "\web\xxxx\htdocs\games\Hangman\WordList.xml"
    "\\web\xxxx\htdocs\games\Hangman\WordList.xml"
    "htdocs\games\Hangman\WordList.xml"
    (Server.MapPath("web\xxxx\htdocs\games\Hangman\WordList.xml"))
    (Server.MapPath("\games\Hangman\WordList.xml"))
    (Server.MapPath("WordList.xml"))

    I am now beginning to think it is not my path references at all but an access to the server issue.

    Any advice will be appreciated.

    Lorraine
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    your path is wrong

    you should use server.mappath("/") which will give you the physical path to the root. You can append the rest of the path




    quote:Originally posted by looseEnds

    I am recieving the following error message:

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    The underlying connection was closed: The remote name could not be resolved.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.WebException: The underlying connection was closed: The remote name could not be resolved.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [WebException: The underlying connection was closed: The remote name could not be resolved.]
    System.Net.HttpWebRequest.CheckFinalStatus() +673
    System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +140
    System.Net.HttpWebRequest.GetResponse() +147
    System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials) +65
    System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +94
    System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +55
    System.Xml.XmlTextReader.CreateScanner() +384
    System.Xml.XmlTextReader.Init() +23
    System.Xml.XmlTextReader.Read() +530
    System.Xml.XmlValidatingReader.ReadWithCollectTextToken() +146
    System.Xml.XmlValidatingReader.Read() +26
    System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +80
    System.Xml.XmlDocument.Load(XmlReader reader) +72
    System.Xml.XmlDocument.Load(String filename) +78
    _2lalaland.hangman.Page_Load(Object sender, EventArgs e)
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +35
    System.Web.UI.Page.ProcessRequestMain() +731

    I have been assuming that the path to my XML file is incorrect. Here is the snippet of code that loads the XML file with the path I use on my localhost:

    Dim xmlDoc As XmlDocument = New XmlDocument()
    Dim xnlList As XmlNodeList
    xmlDoc.PreserveWhitespace = True
    xmlDoc.Load("D://IIS/2lalaland/games/Hangman/Wordlist.xml")
    xnlList = xmlDoc.SelectNodes("//NewWord")


    I have tried the following path references in the xmlDoc.Load() statement and nothing has worked:

    "\\xxxx\htdocs\games\Hangman\WordList.xml"
    "\web\xxxx\htdocs\games\Hangman\WordList.xml"
    "\\web\xxxx\htdocs\games\Hangman\WordList.xml"
    "htdocs\games\Hangman\WordList.xml"
    (Server.MapPath("web\xxxx\htdocs\games\Hangman\WordList.xml"))
    (Server.MapPath("\games\Hangman\WordList.xml"))
    (Server.MapPath("WordList.xml"))

    I am now beginning to think it is not my path references at all but an access to the server issue.

    Any advice will be appreciated.

    Lorraine
    </blockquote id="quote"></font id="quote">
     
  3. I am using the following pieces of code and they are working for me:

    --------------------------
    System.Data.DataSet dsWebGrid = new DataSet("WebGrid");
    string filePath= Server.MapPath("properties.xml");

    dsWebGrid.ReadXml(filePath);
    ------------------------------

    Dim ds As New DataSet
    ds.ReadXml(MapPath("../properties.xml"))

    -----------------------------
    Sub Page_Load(Src As Object, E As EventArgs)

    gxmlpath = server.mappath( "../properties.xml" )

    If Not (IsPostBack)
    DataLoad("Address") '-- sort by ISBN
    End If
    End Sub
     
  4. Thank you Martinelly and Bruce. I got it working.

    You both made my day.

    Lorraine
    [:I]
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page