|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.Xml.Serializationelements 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(); Bryan Phillips
MCSD, MCDBA, MCSE Blog: http://bphillips76.spaces.live.com Show quote "DirkGoes" <DirkG***@discussions.microsoft.com> wrote in message news:4A4405BD-ACC5-404E-A803-AF6FB2CAEF80@microsoft.com: > 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(); 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 Show quote "DirkGoes" <DirkG***@discussions.microsoft.com> wrote in message news:4A4405BD-ACC5-404E-A803-AF6FB2CAEF80@microsoft.com: > 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(); |
|||||||||||||||||||||||