Hi,
I have a class:
public class Note
{
public string name;
public string information;
}
And i Serialize this class, but want to Serialize it to an XmlDocument which
will contain many of these elements.
How do i do this?
Thank you,
Tim. 6 1910
Timothy,
take a look at Chris Lovett's XmlNodeWriter on www.gotdotnet.com [0].
Simply pass the node where you want to insert the serialized XML into the
XmlDocument to an XmlNodeWriter and pass the XmlNodeWriter to the Serialize
method.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
[0] http://gotdotnet.com/Community/User/...d-2e378a25b797
"Timothy V" <tr****@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Hi, I have a class: public class Note { public string name; public string information; }
And i Serialize this class, but want to Serialize it to an XmlDocument which will contain many of these elements.
How do i do this?
Thank you,
Tim.
Timothy,
take a look at Chris Lovett's XmlNodeWriter on www.gotdotnet.com [0].
Simply pass the node where you want to insert the serialized XML into the
XmlDocument to an XmlNodeWriter and pass the XmlNodeWriter to the Serialize
method.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
[0] http://gotdotnet.com/Community/User/...d-2e378a25b797
"Timothy V" <tr****@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Hi, I have a class: public class Note { public string name; public string information; }
And i Serialize this class, but want to Serialize it to an XmlDocument which will contain many of these elements.
How do i do this?
Thank you,
Tim.
Thanks! That works. However, is there any other way to do it? (ie not use
XmlNodeWriter)
Thanks,
Tim.
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:e9**************@TK2MSFTNGP11.phx.gbl... Timothy,
take a look at Chris Lovett's XmlNodeWriter on www.gotdotnet.com [0].
Simply pass the node where you want to insert the serialized XML into the XmlDocument to an XmlNodeWriter and pass the XmlNodeWriter to the Serialize method.
-- HTH Christoph Schittko [MVP] Software Architect, .NET Mentor
[0] http://gotdotnet.com/Community/User/...d-2e378a25b797
"Timothy V" <tr****@msn.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Hi, I have a class: public class Note { public string name; public string information; }
And i Serialize this class, but want to Serialize it to an XmlDocument which will contain many of these elements.
How do i do this?
Thank you,
Tim.
Thanks! That works. However, is there any other way to do it? (ie not use
XmlNodeWriter)
Thanks,
Tim.
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:e9**************@TK2MSFTNGP11.phx.gbl... Timothy,
take a look at Chris Lovett's XmlNodeWriter on www.gotdotnet.com [0].
Simply pass the node where you want to insert the serialized XML into the XmlDocument to an XmlNodeWriter and pass the XmlNodeWriter to the Serialize method.
-- HTH Christoph Schittko [MVP] Software Architect, .NET Mentor
[0] http://gotdotnet.com/Community/User/...d-2e378a25b797
"Timothy V" <tr****@msn.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Hi, I have a class: public class Note { public string name; public string information; }
And i Serialize this class, but want to Serialize it to an XmlDocument which will contain many of these elements.
How do i do this?
Thank you,
Tim.
Nothing that's equally elegant ... and if you want the result to be in an
XmlDocument then it's the way to go.
If you just need a string or a stream, then you can serialize to a
StreamWriter or an XmlTextWriter.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Timothy V" <tr****@msn.com> wrote in message
news:uM**************@tk2msftngp13.phx.gbl... Thanks! That works. However, is there any other way to do it? (ie not use XmlNodeWriter)
Thanks,
Tim.
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in message news:e9**************@TK2MSFTNGP11.phx.gbl... Timothy,
take a look at Chris Lovett's XmlNodeWriter on www.gotdotnet.com [0].
Simply pass the node where you want to insert the serialized XML into the XmlDocument to an XmlNodeWriter and pass the XmlNodeWriter to the Serialize method.
-- HTH Christoph Schittko [MVP] Software Architect, .NET Mentor
[0] http://gotdotnet.com/Community/User/...d-2e378a25b797
"Timothy V" <tr****@msn.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Hi, I have a class: public class Note { public string name; public string information; }
And i Serialize this class, but want to Serialize it to an XmlDocument which will contain many of these elements.
How do i do this?
Thank you,
Tim.
Nothing that's equally elegant ... and if you want the result to be in an
XmlDocument then it's the way to go.
If you just need a string or a stream, then you can serialize to a
StreamWriter or an XmlTextWriter.
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Timothy V" <tr****@msn.com> wrote in message
news:uM**************@tk2msftngp13.phx.gbl... Thanks! That works. However, is there any other way to do it? (ie not use XmlNodeWriter)
Thanks,
Tim.
"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in message news:e9**************@TK2MSFTNGP11.phx.gbl... Timothy,
take a look at Chris Lovett's XmlNodeWriter on www.gotdotnet.com [0].
Simply pass the node where you want to insert the serialized XML into the XmlDocument to an XmlNodeWriter and pass the XmlNodeWriter to the Serialize method.
-- HTH Christoph Schittko [MVP] Software Architect, .NET Mentor
[0] http://gotdotnet.com/Community/User/...d-2e378a25b797
"Timothy V" <tr****@msn.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... Hi, I have a class: public class Note { public string name; public string information; }
And i Serialize this class, but want to Serialize it to an XmlDocument which will contain many of these elements.
How do i do this?
Thank you,
Tim.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Zion Zadik |
last post by:
Dear all,
I have a set of c# data classes which i need to fill their data from xml
files. serialization looks to be the best way to accomplish this task.
Since the data classes are compiled and...
|
by: Kevin Conroy |
last post by:
I'm making a 6-tiered application that is using Xml to tie the various
layers together in a very clean manner. I'm also trying to do this on the
1.1 Framework although I'm willing to switch to the...
|
by: Chris Aitchison |
last post by:
Hello,
I am attempting to have a class that I have written serialize so that it can
be both passed as a parameter or return value for a webservice, and also be
serialized to disk using the...
|
by: Nick Flandry |
last post by:
Hi all,
When I run this code:
XmlSerializer theXS;
try
{
theXS = new XmlSerializer(typeof(TableInfo));
}
catch( System.Exception eAll )
|
by: Kent Boogaart |
last post by:
Hello all,
I have two simple classes: Item and ItemCollection. Item stores a label for
the item and an instance of ItemCollection for all child items.
ItemCollection just stores a collection of...
|
by: SJD |
last post by:
I've just read Christoph Schittko's article on XmlSerializer:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp
. . . and very informative it is too....
|
by: Steve Long |
last post by:
Hello,
I hope this is the right group to post this to. I'm trying to serialize a
class I've written and I'd like to be able to serialze to both binary and
xml formats. Binary serialization is...
|
by: Don McNamara |
last post by:
Hi,
I've hit quite a strange problem with XmlSerializer on my W2K3 server. When
I serialize/deserialize using an exe on my local computer (XP), everything
works fine. When I put the code out on...
|
by: Paul |
last post by:
We currently persist our objects to xml/soap files using a SoapFormatter.
We control the serialization and de-serialization by implementing the
ISerializable and its two interface methods, namely,...
|
by: =?Utf-8?B?U2hhd24=?= |
last post by:
Hi;
I would like to be able to use the XMLSerializer to serialize and
deserialize a dictionary. is that possible? i know that you can serialize an
object that implements the ICollection interface....
|
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...
|
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
|
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...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: 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...
|
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,...
| |