473,769 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Strin g filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(file path,FileMode.O pen);

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

//loading entry from xml file
Entry entry = Global.LoadEntr y("address.xml" );
this.lblCatalog .Text = entry.Catalog;
this.lblName.Te xt = 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>nove l</Catalog>
<Name>Sina</Name>
<Web>http://www.sina.com.cn </Web>
</Addr>
Nov 18 '05 #1
4 2965
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*******@hotm ail.com> wrote in message
news:eP******** ******@TK2MSFTN GP09.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(Strin g filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(file path,FileMode.O pen);

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

//loading entry from xml file
Entry entry = Global.LoadEntr y("address.xml" );
this.lblCatalog .Text = entry.Catalog;
this.lblName.Te xt = 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>nove l</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.InvalidO perationExcepti on: <Addr xmlns=''> was not
expected.

Source Error:

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

Source File: .......global.a sax.cs Line: 95

Stack Trace:

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

Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onReader1.Read4 _
Entry()

[InvalidOperatio nException: There is an error in XML document (2, 2).]
System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader xmlReader,
String encodingStyle)
System.Xml.Seri alization.XmlSe rializer.Deseri alize(Stream stream)
WebAddress.Glob al.LoadEntry(St ring filename) in
c:\inetpub\wwwr oot\webaddress\ global.asax.cs: 95
WebAddress.Defa ult.Page_Load(O bject sender, EventArgs e) in
c:\inetpub\wwwr oot\webaddress\ default.aspx.cs :44
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()

"pei_world" <pe*******@hotm ail.com> wrote in message
news:eP******** ******@TK2MSFTN GP09.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(Strin g filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(file path,FileMode.O pen);

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

//loading entry from xml file
Entry entry = Global.LoadEntr y("address.xml" );
this.lblCatalog .Text = entry.Catalog;
this.lblName.Te xt = 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>nove l</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*******@hotm ail.com> wrote in message
news:uL******** ******@TK2MSFTN GP09.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.InvalidO perationExcepti on: <Addr xmlns=''> was not expected.

Source Error:

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

Source File: .......global.a sax.cs Line: 95

Stack Trace:

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

Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onReader1.Read4 _ Entry()

[InvalidOperatio nException: There is an error in XML document (2, 2).]
System.Xml.Seri alization.XmlSe rializer.Deseri alize(XmlReader xmlReader,
String encodingStyle)
System.Xml.Seri alization.XmlSe rializer.Deseri alize(Stream stream)
WebAddress.Glob al.LoadEntry(St ring filename) in
c:\inetpub\wwwr oot\webaddress\ global.asax.cs: 95
WebAddress.Defa ult.Page_Load(O bject sender, EventArgs e) in
c:\inetpub\wwwr oot\webaddress\ default.aspx.cs :44
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()

"pei_world" <pe*******@hotm ail.com> wrote in message
news:eP******** ******@TK2MSFTN GP09.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(Strin g filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(file path,FileMode.O pen);

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

//loading entry from xml file
Entry entry = Global.LoadEntr y("address.xml" );
this.lblCatalog .Text = entry.Catalog;
this.lblName.Te xt = 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>nove l</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*******@hotm ail.com> wrote in message
news:eP******** ******@TK2MSFTN GP09.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(Strin g filename)
{
//construct the path
String filepath = XMLFilePath + "\\" + filename;
FileStream f = null;
Entry newEntry;

try
{
//open the file
f = new FileStream(file path,FileMode.O pen);

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

//loading entry from xml file
Entry entry = Global.LoadEntr y("address.xml" );
this.lblCatalog .Text = entry.Catalog;
this.lblName.Te xt = 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>nove l</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
6068
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, i.e. the code is not throwing an error (btw the field should link to other pages by clicking them). The strange behavior is, that I copy the file to the remote computer and execute it by typing http://www.smartframe.de/dumm.html (everybody
0
5359
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; public Person() {
1
2015
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: http://www.google.co.uk/search?q=cache:OPDjMJfL50sJ:www.adobe.com/svg/indepth/pdfs/ReadMewin.pdf+adobe+svg+javascript+problem&hl=en&ie=UTF-8#5 4. Due to design limitations of Netscape, avoid using HTML with the following form: <a href="#" onclick="myScriptWhichModifiesSVG()">The problem is that JavaScript responds to the onclick...
1
4335
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 <Include> the Schema doesn't show any of the Elements from the include Schema. But that's to be expected because they are in a different namespace. - If I use <Import> the Schema doesn't show any of the Elements from the
4
59330
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' encoding='UTF-8'?><InSession><PassWord>foo</PassWord><UserName>foo@foo.com</UserName></InSession>";XmlSerializer serializer = new XmlSerializer(typeof(cXmlBS));XmlTextReader tr = new XmlTextReader(new System.IO.StringReader(xin));cXmlBS cx =...
1
4618
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" encoding="UTF-8"?> <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2006-06-09T14:07:13"> <Applications> <ApplicationID>0</ApplicationID>
2
12625
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 string, the string is an object serialized into XML. The XML returned could look like: ...
1
1417
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 = xmlDoc.SelectNodes("/html/head/title"); after this... list.Count is 0, but when I delete xmlns attribute (Example2.html, list.Count is 1... but I want list.Count == 1 result for Example.html, too ...so what I have to do ?
11
6682
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 none of the tagging that I have written in. Remove the xmlns atts from the xml and all is fine. I’ve tried adding in the xmlns from the xml into the xsl:stylesheet element of the xsl but get the same result. This is the same run on xmlspy and with...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.