473,397 Members | 2,056 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,397 software developers and data experts.

XML Deserialization - xmlns not expected

I'm using XmlSerializer to deserialize an xml into classes. The error I recieve is:

Exception:There is an error in XML document (2, 2).
Inner Exception: <applications xmlns='urn:xmlns:COMMONCENSUS:CommonFormat:IMSchem a'> was not expected.

I've read numerous threads on this but none seem to help with this particular issue. I've included the xml, and the Schema file below as well as the code. First post also, so I'm not sure how to add the code in a more readable way. Thanks in advance.

xml:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<applications xmlns="urn:xmlns:COMMONCENSUS:CommonFormat:IMSchem a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exportType="T">
<application guid="{9A44D2FF-90EB-45BE-BC88-CF2107B2CA4C}" xmlns="urn:xmlns:COMMONCENSUS:CommonFormat:IMSchem a">
-----
</application>
</applications>

xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:xmlns:COMMONCENSUS:CommonFormat:IMSchem a" xmlns:NS="urn:xmlns:COMMONCENSUS:CommonFormat:IMSc hema" targetNamespace="urn:xmlns:COMMONCENSUS:CommonForm at:IMSchema" elementFormDefault="qualified">
<xs:element name="applications">
<xs:complexType>
<xs:sequence>
<xs:element name="application" type="ApplicationType" minOccurs="0" maxOccurs="unbounded">
<xs:key name="personKey">
<xs:selector xpath="persons/person" />
<xs:field xpath="id" />
</xs:key>
<xs:keyref name="applicantKeyRef" refer="personKey">
<xs:selector xpath="applicantID" />
<xs:field xpath="." />
</xs:keyref>
<xs:keyref name="insuredKeyRef" refer="personKey">
<xs:selector xpath="coverages/coverage/insuredID" />
<xs:field xpath="." />
</xs:keyref>
</xs:element>
</xs:sequence>
<xs:attribute name="exportType" type="ExportType" />
</xs:complexType>
</xs:element>
-----
</xs:schema>

Code:
// Read the xml file
TextReader reader = new StreamReader("C:\\CommonSensusXml\\Policy_87654321 _210_Dion-Paul_WSA.xml");

//Application Type
XmlSerializer serializer = new XmlSerializer(typeof(ApplicationType));
ApplicationType appType = (ApplicationType)serializer.Deserialize(reader);
Mar 17 '09 #1
1 4236
I've added this to the xml topic...
Mar 18 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Linus | last post by:
Hi, I'm having problems with some very simple deserialization code and would appreciate it very much if I could get some help here. The following is the code:...
4
by: Mike Sarbu | last post by:
Hello all, I have an XML file like this: <?xml version="1.0" encoding="utf-8"?> <SomeObject xmlns="http://www.abcinc.com/objectdefinition"...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
7
by: PeterW | last post by:
I have an xml file containing some stuff. I use xsd to generate a schema and again to create classes from the schemas. added using System, System.IO; added to all classes added namespace ROC...
3
by: John Glover | last post by:
To whoever can help, I've been having a problem with XML deserialization lately. I needed to serialize and deserialze two objects which inherited from Hashtable. Because IDictionary...
1
by: John Smith | last post by:
This is what I am trying to do: FileStream fs = new FileStream("C:\\request1.xml", FileMode.Open); XmlSerializer x = new XmlSerializer(typeof(PodpisaniDokumentTip)); PodpisaniDokumentTip doc =...
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...
8
by: nwbabcock | last post by:
I'm using XmlSerializer in C# to deserialize an xml into classes. First I generated the code from the schema using xsd.exe The error I recieve is: Exception:There is an error in XML document (2,...
3
by: Stubbie | last post by:
have an object (InputFile) that I am able to successfully serialize to XML and deserialize back into the object through an IXmlSerializable interface. Now I'm trying to serialize a List<InputFile>...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
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...

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.