System.Xml.Serialization

G

Guest

I have generated a class for serialization using XSD.exe. One of my xml
elements always contains html data but the serializer does not pick up this
content. If the element contains only text it picks it up as expected.

I assume it is because the serializer thinks <html> is an element that is
not in the class so it ignores it. However how can I tell the serializer to
get all the content of an element no matter what it contains?

An example of the element and the data it contains is:

<DataContent>
<html><head><title/></head><body><p>Test</p></body></html>
</DataContent>

XmlSerializer serializer = new XmlSerializer(l_NewsMLDocument.GetType());
Stream stream = new FileStream("c:\\DirkTemp\\" + l_fiTemp.Name,
FileMode.Create,
FileAccess.Write, FileShare.None);
serializer.Serialize(stream, l_NewsMLDocument);
stream.Close();
 
B

Bryan Phillips

By default, the XmlSerializer class will ignore unknown elements. You
need to add an event handler to the UnknownNode event of the
XmlSerializer class in order to programmatically handle these elements.

Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top