Re: Access to xml file error

Discussion in 'ASP .Net' started by Marina, Feb 10, 2004.

  1. Marina

    Marina Guest

    According to this, this isn't a security issue. The error suggest that the
    xml file is invalid.

    "Mark" <> wrote in message
    news:...
    > Here is an error I am getting when aspx page (TreeView) is trying to

    access an xml data.
    > I know about an anonymous access. It's set.
    > Same code works fine on my computer.
    >
    > Server Error in '/processtree' Application.
    > --------------------------------------------------------------------------

    ------
    >
    > The data at the root level is invalid. Line 1, position 1.
    > 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.Xml.XmlException: The data at the root level is

    invalid. Line 1, position 1.
    >
    > 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:
    >
    >
    > [XmlException: The data at the root level is invalid. Line 1, position 1.]
    > System.Xml.XmlTextReader.ParseRoot() +295
    > System.Xml.XmlTextReader.Read() +127
    > Microsoft.Web.UI.WebControls.TreeView.ReadXmlSrc(String TreeNodeSrc,

    String TreeNodeXsltSrc, String strOuter) +127
    > Microsoft.Web.UI.WebControls.TreeView.ReadTreeNodeXmlSrc() +70
    > Microsoft.Web.UI.WebControls.TreeView.OnInit(EventArgs e) +90
    > System.Web.UI.Control.InitRecursive(Control namingContainer) +241
    > System.Web.UI.Control.InitRecursive(Control namingContainer) +179
    > System.Web.UI.Control.InitRecursive(Control namingContainer) +179
    > System.Web.UI.Page.ProcessRequestMain() +174
    >
    >
    >
    >
    > --------------------------------------------------------------------------

    ------
    > Version Information: Microsoft .NET Framework Version:1.1.4322.573;

    ASP.NET Version:1.1.4322.573
    Marina, Feb 10, 2004
    #1
    1. Advertising

  2. Data is not invalid.
    =?Utf-8?B?TWFyaw==?=, Feb 10, 2004
    #2
    1. Advertising

  3. Marina

    nathyx

    Joined:
    Oct 13, 2008
    Messages:
    2
    I received an Error message Exception Details: System.Xml.XmlException: The data at t

    Please i need help with this error. I am creating a web blog where i will store xml files in a folder called entries, the page that will display the xml files i named as hotelweblog.aspx, and the page that will enter the data to create new xml files in the entries folder i named as Edit.aspx. I can create new xml files with the edit page but when displaying in the hotelweblog page it returns the below error. Mean while when i open my xml files in IE it opens without error but i dont know why it wont just display.

    Exception Details: System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1.

    Source Error:


    Line 81: FileStream file = new FileStream(filepath, FileMode.Open);
    Line 82: XmlSerializer serializer = new XmlSerializer(typeof(Entry));
    Line 83: Entry newEntry = (Entry)serializer.Deserialize(file);
    Line 84: file.Close();
    Line 85: newEntry.Timestamp = new FileInfo(filepath).LastWriteTime;


    Source File: c:\inetpub\wwwroot\hotelweb\global.asax.cs Line: 83

    Stack Trace:


    [XmlException: The data at the root level is invalid. Line 1, position 1.]
    System.Xml.XmlTextReader.ParseRoot() +295
    System.Xml.XmlTextReader.Read() +127
    System.Xml.XmlReader.MoveToContent() +75
    Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read4_Entry() +16

    [InvalidOperationException: There is an error in XML document (0, 0).]
    System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
    System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events)
    System.Xml.Serialization.XmlSerializer.Deserialize(Stream stream)
    HotelWeb.Global.LoadEntry(String filename) in c:\inetpub\wwwroot\hotelweb\global.asax.cs:83
    HotelWeb.Global.LoadAllEntries() in c:\inetpub\wwwroot\hotelweb\global.asax.cs:97
    HotelWeb.HotelWebLog.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\hotelweb\hotelweblog.aspx.cs:31
    System.Web.UI.Control.OnLoad(EventArgs e)
    System.Web.UI.Control.LoadRecursive()
    System.Web.UI.Page.ProcessRequestMain()


    My Global.aspx i have checked so many times and found no errors. below is my global.aspx.

    public static Entry LoadEntry(String filename)
    {
    String filepath = EntryFilePath + "\\" + filename;
    FileStream file = new FileStream(filepath, FileMode.Open);
    XmlSerializer serializer = new XmlSerializer(typeof(Entry));
    Entry newEntry = (Entry)serializer.Deserialize(file);
    file.Close();
    newEntry.Timestamp = new FileInfo(filepath).LastWriteTime;
    newEntry.Filename = filename;
    return newEntry;
    }
    public static Entry[] LoadAllEntries()
    {
    DirectoryInfo entryFolder = new DirectoryInfo(EntryFilePath);
    FileInfo[] files = entryFolder.GetFiles();
    Entry[] entries = new Entry[files.Length];
    int index = files.Length -1;
    foreach(FileInfo file in files)
    {
    entries[index] = LoadEntry(file.Name);
    index--;
    }
    return entries;
    }

    Please i need this help if anyone can. Thanks
    nathyx, Oct 13, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sachin
    Replies:
    1
    Views:
    349
    Tjerk Wolterink
    Dec 1, 2005
  2. jkflens
    Replies:
    2
    Views:
    1,458
    jkflens
    May 30, 2006
  3. Replies:
    1
    Views:
    406
    Mark Fitzpatrick
    Feb 25, 2007
  4. Savvoulidis Iordanis

    XML data access or DB data access ?

    Savvoulidis Iordanis, Jan 7, 2009, in forum: ASP .Net
    Replies:
    2
    Views:
    408
    Savvoulidis Iordanis
    Jan 7, 2009
  5. Erik Wasser
    Replies:
    5
    Views:
    445
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page