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

how to deserialize a sub class

hi,all
I'v gotten a problerm of deserializing xml to object.the scene is:
I generated the classes using xsd tools including a class A and sub-class B,
then I deserialize from XmlNodeReader only has B's node, and no exception was
catched,and instance of B has been constructed,but has no data .

thanks for any help
Nov 12 '05 #1
1 1300
I got the key of the problerm:mismatch of the namespace.
the xml' namespace has prefix,but the XmlRootAttribute not .code as following:

class define:
........
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://www.xxx.com/")]
[System.Xml.Serialization.XmlRootAttribute("B",
Namespace="http://www.xxx.com/", IsNullable=false)]
public class B: A{

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataT ype="NMTOKEN")]
public string LinkedID;

/// <remarks/>
public addressType Sender;
......
}
-------------------------------------------------------------------
and XML file is:
------------------------------------------------------------------
<ns:B xmlns:ns="http://www.xxx.com/">
.........
</ns:B>

Nov 12 '05 #2

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

Similar topics

4
by: Bob Rock | last post by:
Hello, I've got an xml stream that I'd need to deserialize into an instance of a given class A. I'd like to create an instance method on class A (method Deserialize) that takes this XML stream...
2
by: Greg | last post by:
I'm writing a class in C# .... I have a collection calls Reports made up of Report objects. I'm trying to deserialize an XML file that looks like : <Reports> <Report> <Title>some title</Title>...
0
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
1
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
2
by: alexandre martins | last post by:
Every time i try to make Deserialize the computer gives me the folowing error: "End of Stream encountered before parsing was complete" the code that i'm running is simple and is based on an...
4
by: George Addison | last post by:
I understand this might not be the optimal method of deserialization, but how can I deserialize a class to itself? Something like: Public Sub New(Optional ByVal filename as string = Nothing)...
1
by: Stephen Travis | last post by:
I would like an Object's Constructor to create itself by deserializing from XML. Is there an easy way to do this? I could use a separate function to deserialize to an object but I'd like to do it...
0
by: Matt S | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element...
4
by: Anbu | last post by:
Hi All, I need to Deserialize the SoapService's SoapEnvelope response object. Here is the Body of the SoapEnvelope received as respone, <q1:serviceResponse...
2
by: Joe | last post by:
Hi I have a Generics List in a PropertyGrid I am able to Serialize it to XML but when I try to deserialize back to the class of the PropertyGrid The Constructor doesn't seem to fire to reload...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.