473,396 Members | 1,809 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,396 software developers and data experts.

ASP.NET xmlns=''> was not expected problem

I have followed a example from a book exactly, but it seems not working at
all.
can anyone tell me what is going on?
========= Global.asax.cs ============

public static Entry LoadEntry(String filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(filepath,FileMode.Open);

//create a serializer...
XmlSerializer serializer = new XmlSerializer(typeof(Entry));
newEntry = (Entry)serializer.Deserialize(f);
}
finally
{
//close the file
f.Close();
}
//retrun the entry..
return newEntry;
}
====== default.aspx.cs =======

//loading entry from xml file
Entry entry = Global.LoadEntry("address.xml");
this.lblCatalog.Text = entry.Catalog;
this.lblName.Text = entry.Name;
this.lblAddress.Text = entry.Address;

===== address.xml ========

<?xml version="1.0" encoding="utf-8" ?>
<Addr xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Catalog>novel</Catalog>
<Name>Sina</Name>
<Web>http://www.sina.com.cn</Web>
</Addr>
Nov 18 '05 #1
4 2941
Pei_World,

What is the error you are receiving?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"pei_world" <pe*******@hotmail.com> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
I have followed a example from a book exactly, but it seems not working at
all.
can anyone tell me what is going on?
========= Global.asax.cs ============

public static Entry LoadEntry(String filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(filepath,FileMode.Open);

//create a serializer...
XmlSerializer serializer = new XmlSerializer(typeof(Entry));
newEntry = (Entry)serializer.Deserialize(f);
}
finally
{
//close the file
f.Close();
}
//retrun the entry..
return newEntry;
}
====== default.aspx.cs =======

//loading entry from xml file
Entry entry = Global.LoadEntry("address.xml");
this.lblCatalog.Text = entry.Catalog;
this.lblName.Text = entry.Name;
this.lblAddress.Text = entry.Address;

===== address.xml ========

<?xml version="1.0" encoding="utf-8" ?>
<Addr xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Catalog>novel</Catalog>
<Name>Sina</Name>
<Web>http://www.sina.com.cn</Web>
</Addr>

Nov 18 '05 #2

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

<Addr xmlns=''> was not expected.
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.InvalidOperationException: <Addr xmlns=''> was not
expected.

Source Error:

Line 93: //create a serializer...
Line 94: XmlSerializer serializer = new
XmlSerializer(typeof(Entry));
Line 95: newEntry = (Entry)serializer.Deserialize(f);
Line 96: }
Line 97: finally

Source File: .......global.asax.cs Line: 95

Stack Trace:

[InvalidOperationException: <Addr xmlns=''> was not expected.]

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read4_
Entry()

[InvalidOperationException: There is an error in XML document (2, 2).]
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
String encodingStyle)
System.Xml.Serialization.XmlSerializer.Deserialize (Stream stream)
WebAddress.Global.LoadEntry(String filename) in
c:\inetpub\wwwroot\webaddress\global.asax.cs:95
WebAddress.Default.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\webaddress\default.aspx.cs:44
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

"pei_world" <pe*******@hotmail.com> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
I have followed a example from a book exactly, but it seems not working at
all.
can anyone tell me what is going on?
========= Global.asax.cs ============

public static Entry LoadEntry(String filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(filepath,FileMode.Open);

//create a serializer...
XmlSerializer serializer = new XmlSerializer(typeof(Entry));
newEntry = (Entry)serializer.Deserialize(f);
}
finally
{
//close the file
f.Close();
}
//retrun the entry..
return newEntry;
}
====== default.aspx.cs =======

//loading entry from xml file
Entry entry = Global.LoadEntry("address.xml");
this.lblCatalog.Text = entry.Catalog;
this.lblName.Text = entry.Name;
this.lblAddress.Text = entry.Address;

===== address.xml ========

<?xml version="1.0" encoding="utf-8" ?>
<Addr xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Catalog>novel</Catalog>
<Name>Sina</Name>
<Web>http://www.sina.com.cn</Web>
</Addr>

Nov 18 '05 #3
Pei,

It looks like the error is actually in your xml document itself.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"pei_world" <pe*******@hotmail.com> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...

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

<Addr xmlns=''> was not expected.
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.InvalidOperationException: <Addr xmlns=''> was not expected.

Source Error:

Line 93: //create a serializer...
Line 94: XmlSerializer serializer = new
XmlSerializer(typeof(Entry));
Line 95: newEntry = (Entry)serializer.Deserialize(f);
Line 96: }
Line 97: finally

Source File: .......global.asax.cs Line: 95

Stack Trace:

[InvalidOperationException: <Addr xmlns=''> was not expected.]

Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read4_ Entry()

[InvalidOperationException: There is an error in XML document (2, 2).]
System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader,
String encodingStyle)
System.Xml.Serialization.XmlSerializer.Deserialize (Stream stream)
WebAddress.Global.LoadEntry(String filename) in
c:\inetpub\wwwroot\webaddress\global.asax.cs:95
WebAddress.Default.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\webaddress\default.aspx.cs:44
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

"pei_world" <pe*******@hotmail.com> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
I have followed a example from a book exactly, but it seems not working at all.
can anyone tell me what is going on?
========= Global.asax.cs ============

public static Entry LoadEntry(String filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(filepath,FileMode.Open);

//create a serializer...
XmlSerializer serializer = new XmlSerializer(typeof(Entry));
newEntry = (Entry)serializer.Deserialize(f);
}
finally
{
//close the file
f.Close();
}
//retrun the entry..
return newEntry;
}
====== default.aspx.cs =======

//loading entry from xml file
Entry entry = Global.LoadEntry("address.xml");
this.lblCatalog.Text = entry.Catalog;
this.lblName.Text = entry.Name;
this.lblAddress.Text = entry.Address;

===== address.xml ========

<?xml version="1.0" encoding="utf-8" ?>
<Addr xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Catalog>novel</Catalog>
<Name>Sina</Name>
<Web>http://www.sina.com.cn</Web>
</Addr>


Nov 18 '05 #4
I try to retrieve data in my adapter, no problem at all.
can you check it for me? Xml file is also included.
"pei_world" <pe*******@hotmail.com> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
I have followed a example from a book exactly, but it seems not working at
all.
can anyone tell me what is going on?
========= Global.asax.cs ============

public static Entry LoadEntry(String filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(filepath,FileMode.Open);

//create a serializer...
XmlSerializer serializer = new XmlSerializer(typeof(Entry));
newEntry = (Entry)serializer.Deserialize(f);
}
finally
{
//close the file
f.Close();
}
//retrun the entry..
return newEntry;
}
====== default.aspx.cs =======

//loading entry from xml file
Entry entry = Global.LoadEntry("address.xml");
this.lblCatalog.Text = entry.Catalog;
this.lblName.Text = entry.Name;
this.lblAddress.Text = entry.Address;

===== address.xml ========

<?xml version="1.0" encoding="utf-8" ?>
<Addr xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Catalog>novel</Catalog>
<Name>Sina</Name>
<Web>http://www.sina.com.cn</Web>
</Addr>

Nov 18 '05 #5

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

Similar topics

4
by: Torsten Reiners | last post by:
Hi, it might be a simple solution but I do not see it. The problem is that I have the following file stored on my local harddrive. All references are URL to a remote computer. It is working,...
0
by: Julia | last post by:
Hi,i am trying to DeSerialize the following class from an XML string and i get "<root xmlns=''> was not expected." public class Person { private string m_Name; private string m_Phone; ...
1
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: ...
1
by: Stephen Edgecombe | last post by:
Hi Environment: Visual Studio .NET 2003 (vb) I am developing an XSD Schema and want to include some building blocks from another source, so they have a different namespace. - If I use an...
4
by: Shailendra Batham | last post by:
Hi guys,Does any1 know what this error is all about, what I am trying to do is deserialize a XML, below is my code, let me know what I am doing wrongpublic class test{xin = "<?xml version='1.0'...
1
by: Rob R. Ainscough | last post by:
I'm using XmlSerializer to read the an XML file into an object collection. As soon as I .Deserialize(myFileStream) I get the above error: my XML looks like <?xml version="1.0"...
2
by: snowie | last post by:
I have a simillar problem to what others have had before me. I just can't find the solution in any earlier post here at the scripts (or any other forum). I am calling a web service that returns a...
1
by: neuron | last post by:
Hi, the problem is: XmlReader xmlReader = XmlReader.Create("D:\\temp\\Example.html"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlReader); XmlNodeList list =...
11
by: eb621 | last post by:
Hi, I have an xsl transform to convert xml into another (non-standard) data structure. All is fine until I have an xml file with xmlns atts and then all I get is the element contents output with...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.