Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Access to xml file error

Reply
Thread Tools

Re: Access to xml file error

 
 
Marina
Guest
Posts: n/a
 
      02-10-2004
According to this, this isn't a security issue. The error suggest that the
xml file is invalid.

"Mark" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWFyaw==?=
Guest
Posts: n/a
 
      02-10-2004
Data is not invalid.
 
Reply With Quote
 
 
 
 
nathyx nathyx is offline
Junior Member
Join Date: Oct 2008
Posts: 2
 
      10-13-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
Problem to insert an XML-element by XSLT-converting from one XML-file into another XML-file jkflens XML 2 05-30-2006 09:41 AM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
can we access more than one xml file from one single xls file. sachin XML 1 12-01-2005 09:56 AM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM



Advertisments