473,659 Members | 2,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Deserialization - xmlns not expected

6 New Member
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:xmln s:COMMONCENSUS: CommonFormat:IM Schema'> 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:xmln s:COMMONCENSUS: CommonFormat:IM Schema" xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" exportType="T">
<application guid="{9A44D2FF-90EB-45BE-BC88-CF2107B2CA4C}" xmlns="urn:xmln s:COMMONCENSUS: CommonFormat:IM Schema">
-----
</application>
</applications>

xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:xmln s:COMMONCENSUS: CommonFormat:IM Schema" xmlns:NS="urn:x mlns:COMMONCENS US:CommonFormat :IMSchema" targetNamespace ="urn:xmlns:COM MONCENSUS:Commo nFormat:IMSchem a" elementFormDefa ult="qualified" >
<xs:element name="applicati ons">
<xs:complexType >
<xs:sequence>
<xs:element name="applicati on" type="Applicati onType" minOccurs="0" maxOccurs="unbo unded">
<xs:key name="personKey ">
<xs:selector xpath="persons/person" />
<xs:field xpath="id" />
</xs:key>
<xs:keyref name="applicant KeyRef" refer="personKe y">
<xs:selector xpath="applican tID" />
<xs:field xpath="." />
</xs:keyref>
<xs:keyref name="insuredKe yRef" refer="personKe y">
<xs:selector xpath="coverage s/coverage/insuredID" />
<xs:field xpath="." />
</xs:keyref>
</xs:element>
</xs:sequence>
<xs:attribute name="exportTyp e" type="ExportTyp e" />
</xs:complexType>
</xs:element>
-----
</xs:schema>

Code:
// Read the xml file
TextReader reader = new StreamReader("C :\\CommonSensus Xml\\Policy_876 54321_210_Dion-Paul_WSA.xml");

//Application Type
XmlSerializer serializer = new XmlSerializer(t ypeof(Applicati onType));
ApplicationType appType = (ApplicationTyp e)serializer.De serialize(reade r);
Mar 17 '09 #1
1 4246
nwbabcock
6 New Member
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
1547
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: ========================================================= XmlReader reader = new XmlTextReader("test.xml"); XmlValidatingReader vr = new XmlValidatingReader(reader);
4
3151
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" xmlns:someobj=http://www.abcinc.com/objectdefinition> ...... </SomeObject>
3
9791
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 response. As a result of seraching news groups I guessed that the SOAP response defines an array element in a way that causes the dotnet deserialization routines to put the content in a generic object array (object) BUT the content is supposed to...
7
1794
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 added deserialize() method as follows to AWLR2 class: public AWLR2 deserialize(string xmlString)
3
4990
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 implementations cannot be serialized, I had to take matters into my own hands by implementing a wrapper over the Hashtable which implemted IXmlSerializable. I called it XmlHashtable. It has, among other convenience methods, a method
1
1604
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 = (PodpisaniDokumentTip)x.Deserialize(fs); And this is my class (auto generated from WSDL):
2
12615
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: ...
8
30737
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, 2). Inner Exception: <applications xmlns='urn:xmlns:COMMONCENSUS:CommonFormat:IMSchem a'> was not expected. I've read numerous threads and realize it is a namespace issue, but none seem to help with this particular problem. I've included the xml,...
3
8466
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> to XML. I'm using the following code: XmlSerializer s = new XmlSerializer(typeof(List<Inputs.InputFile>)); TextWriter w = new StreamWriter("c:\\out.xml"); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", "");...
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8627
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
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
5649
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
4175
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
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
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.