473,394 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Loading XML file into XMLDocument

Hey There!...

I've been dealing for hours trying to figure out why do I get the
following error message:

Type 'System.Xml.XmlDocument' in Assembly 'System.Xml,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is
not marked as serializable.

I'm using the following method to get the XML:
private XmlDocument loadXmlFile()
{
XmlDocument xmlDoc= new XmlDocument();

try {
xmlDoc.LoadXml(File.ReadAllText(Server.MapPath("~/
links.xml")));
} catch (Exception) {
throw;
}

return xmlDoc;
}

Actually, the method works just fine (it opens the xml file and
returns an XmlDocument with all of the content). But, when the .aspx
page is going to display ... boom! ... i get the error message shown
above.

Does anybody have an idea of how to solve this?

In advance, thanx for your time and help.

Jan 30 '07 #1
1 9416
Pesci Drums wrote:
I've been dealing for hours trying to figure out why do I get the
following error message:

Type 'System.Xml.XmlDocument' in Assembly 'System.Xml,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is
not marked as serializable.
I am not sure that error is related to the code snippet below. Where
else does your code make use of System.Xml.XmlDocument?

I'm using the following method to get the XML:
private XmlDocument loadXmlFile()
{
XmlDocument xmlDoc= new XmlDocument();

try {
xmlDoc.LoadXml(File.ReadAllText(Server.MapPath("~/
links.xml")));
This comment is not related to your error message but why don't you
simply use
xmlDoc.Load(Server.MapPath("~/links.xml"))
? It does not make sense to read all contents into a string first, and
with that approach you might get encoding/decoding errors.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Morten Nielsen | last post by:
I'm trying to load an XML file, that references a DTD without a relative URL. This renders the error: Could not find file "C:\WINNT\system32\capabilities_1_1_0.dtd". Here's the XML I'm loading:...
1
by: Dave | last post by:
Can you load an XmlDocument with a file located on a network share? I thought maybe the XmlResolver could be used XmlUrlResolver resolver = new XmlUrlResolver() resolver.Credentials =...
2
by: Sandy | last post by:
I've saved an xml string into a file and loaded it into a dataset then displayed it into a datagrid: XmlDocument doc = new XmlDocument(); doc.loadXml(stringXml);...
7
by: Christofer Dutz | last post by:
Hi, I am trying to read a XML-File which I marked as embedded resource from within the code of my DLL. Unfortunately it doesn't work. On my search for the error I inserted some code for...
4
by: Gustaf Liljegren | last post by:
This may be a question of taste, but if there is a best practice, I want to know. I have two choises: SomeClass s = new SomeClass(file); // Load the file or SomeClass s = new SomeClass();...
7
by: emma_middlebrook | last post by:
Hi In one of our test suites we load an xml document (it's actually .svg). I'm trying to find some way of stopping the eventual call to HttpWebRequest.GetResponse which I presume it's doing when...
6
by: cmorgan76 | last post by:
This is a 2 part question: Part 1: I am accesing a web service that returns an xml string of user information. I am attempting to load the XML into an XMLDocument, save the document, load it...
1
by: sasiphyd | last post by:
I have used an ajax file furnaces.html with code as below.The file furnacedata.php is used to generate XML dynamically and this appears to working well. timerID is used to reload the XML data at...
1
by: JustinLee | last post by:
Hi, I have a small app that saves and loads data in XML format. Basically I have 2 methods. They each load data from a different XML documents. They both load data the same way. Everything works...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.