Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Re: Access to xml file error (http://www.velocityreviews.com/forums/t72734-re-access-to-xml-file-error.html)

Marina 02-10-2004 06:51 PM

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

"Mark" <anonymous@discussions.microsoft.com> wrote in message
news:281760DE-17EB-4177-9E02-F20AD693558F@microsoft.com...
> 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(S tring TreeNodeSrc,

String TreeNodeXsltSrc, String strOuter) +127
> Microsoft.Web.UI.WebControls.TreeView.ReadTreeNode XmlSrc() +70
> Microsoft.Web.UI.WebControls.TreeView.OnInit(Event Args 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



=?Utf-8?B?TWFyaw==?= 02-10-2004 07:06 PM

Re: Access to xml file error
 
Data is not invalid.

nathyx 10-13-2008 06:04 AM

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.XmlS erializationReader1.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


All times are GMT. The time now is 01:39 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.