470,615 Members | 2,182 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,615 developers. It's quick & easy.

XML deserialization (error)

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):

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Xml",
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://www.example.org/PodpisaniDokument")]
public partial class PodpisaniDokumentTip {

This is XML:

<sgn:PodpisaniDokument xmlns:sgn="http://www.example.org/PodpisaniDokument">

This is the error message during deserialization:


System.InvalidOperationException: <PodpisaniDokument
xmlns='http://www.example.org/PodpisaniDokument'> was not expected.
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReaderPodpisaniDokumentTip.Read36_Podp isaniDokument()

What is wrong?

I've found this:



but it doesn't help me. :(
Apr 11 '06 #1
1 1446

Got it! :>

I've changed this:

public partial class PodpisaniDokumentTip {

into this:

[System.Xml.Serialization.XmlRoot("PodpisaniDokumen t", Namespace =
public partial class PodpisaniDokumentTip {

and it worked. :>

I hope someone else will find this useful once.
Apr 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Serg | last post: by
2 posts views Thread by Meta-Meta | last post: by
4 posts views Thread by Mike Sarbu | last post: by
3 posts views Thread by Amadelle | last post: by
3 posts views Thread by parrot toes | last post: by
reply views Thread by Miguel RS | last post: by
reply views Thread by =?Utf-8?B?UGllcmNlQnJvc25hbg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.