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

mixed XML serialization

I have an object that serializes back and forth.
I would like to have some objects not serialize ..and when
I read that info back into the class, have this item be
null ( or something like it ).

I modified a class I made by XSD.exe by adding these
values ( drvltr, disknum) , but I found when I wrote the
class out to file and retrieved it, the values were
persisted.

If this is reasonable, how do I approach it ? Thanks

In the example below, the tool inserts the declaration
[System.Xml.Serialization.XmlAttributeAttribute()]
for each attribute. Therefore I added the the attributes
drvltr and disknum because I reasoned maybe without the
declaration, they would be ignored.

[System.Xml.Serialization.XmlAttributeAttribute()]
public string uniqueid;
public string drvltr;
public string disknum;

Nov 15 '05 #1
6 2006
Hi Andrew,

To exclude a field of a class when serializing, you can add the following
attribute before the declaration of this memeber variable. For example, if
you don't want "disknum" to be serialized, you can try the following code:

[System.NonSerialized()]
public string disknum;

This attribute only affects on the declaration of "disknum", and will be
ignored on latter fields.

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: "andrewcw" <an************@boeing.com>
| Sender: "andrewcw" <an************@boeing.com>
| Subject: mixed XML serialization
| Date: Sun, 5 Oct 2003 20:01:54 -0700
| Lines: 23
| Message-ID: <00****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcOLtjJlFwrQ4RTLS9eveNRajrJ6Ew==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:189133
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I have an object that serializes back and forth.
| I would like to have some objects not serialize ..and when
| I read that info back into the class, have this item be
| null ( or something like it ).
|
| I modified a class I made by XSD.exe by adding these
| values ( drvltr, disknum) , but I found when I wrote the
| class out to file and retrieved it, the values were
| persisted.
|
| If this is reasonable, how do I approach it ? Thanks
|
| In the example below, the tool inserts the declaration
| [System.Xml.Serialization.XmlAttributeAttribute()]
| for each attribute. Therefore I added the the attributes
| drvltr and disknum because I reasoned maybe without the
| declaration, they would be ignored.
|
| [System.Xml.Serialization.XmlAttributeAttribute()]
| public string uniqueid;
| public string drvltr;
| public string disknum;
|
|

Nov 15 '05 #2
Hi Andrew,

To exclude a field of a class when serializing, you can add the following
attribute before the declaration of this memeber variable. For example, if
you don't want "disknum" to be serialized, you can try the following code:

[System.NonSerialized()]
public string disknum;

This attribute only affects on the declaration of "disknum", and will be
ignored on latter fields.

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: "andrewcw" <an************@boeing.com>
| Sender: "andrewcw" <an************@boeing.com>
| Subject: mixed XML serialization
| Date: Sun, 5 Oct 2003 20:01:54 -0700
| Lines: 23
| Message-ID: <00****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcOLtjJlFwrQ4RTLS9eveNRajrJ6Ew==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:189133
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I have an object that serializes back and forth.
| I would like to have some objects not serialize ..and when
| I read that info back into the class, have this item be
| null ( or something like it ).
|
| I modified a class I made by XSD.exe by adding these
| values ( drvltr, disknum) , but I found when I wrote the
| class out to file and retrieved it, the values were
| persisted.
|
| If this is reasonable, how do I approach it ? Thanks
|
| In the example below, the tool inserts the declaration
| [System.Xml.Serialization.XmlAttributeAttribute()]
| for each attribute. Therefore I added the the attributes
| drvltr and disknum because I reasoned maybe without the
| declaration, they would be ignored.
|
| [System.Xml.Serialization.XmlAttributeAttribute()]
| public string uniqueid;
| public string drvltr;
| public string disknum;
|
|

Nov 15 '05 #3
Thanks - that is exactly what I needed to know !!!
-----Original Message-----
Hi Andrew,

To exclude a field of a class when serializing, you can add the followingattribute before the declaration of this memeber variable. For example, ifyou don't want "disknum" to be serialized, you can try the following code:
[System.NonSerialized()]
public string disknum;

This attribute only affects on the declaration of "disknum", and will beignored on latter fields.

Does this answer your question? If anything is unclear, please feel free toreply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers norights."

--------------------
| Content-Class: urn:content-classes:message
| From: "andrewcw" <an************@boeing.com>
| Sender: "andrewcw" <an************@boeing.com>
| Subject: mixed XML serialization
| Date: Sun, 5 Oct 2003 20:01:54 -0700
| Lines: 23
| Message-ID: <00****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcOLtjJlFwrQ4RTLS9eveNRajrJ6Ew==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:189133| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I have an object that serializes back and forth.
| I would like to have some objects not serialize ..and when| I read that info back into the class, have this item be
| null ( or something like it ).
|
| I modified a class I made by XSD.exe by adding these
| values ( drvltr, disknum) , but I found when I wrote the| class out to file and retrieved it, the values were
| persisted.
|
| If this is reasonable, how do I approach it ? Thanks
|
| In the example below, the tool inserts the declaration
| [System.Xml.Serialization.XmlAttributeAttribute()]
| for each attribute. Therefore I added the the attributes| drvltr and disknum because I reasoned maybe without the
| declaration, they would be ignored.
|
| [System.Xml.Serialization.XmlAttributeAttribute()]
| public string uniqueid;
| public string drvltr;
| public string disknum;
|
|

.

Nov 15 '05 #4
Hi Andrew,

"andrewcw" <an************@boeing.com> wrote in message
news:23*****************************@phx.gbl...

Kevin, something is not right, I modified the class file
and it wrote out the fields and read them back in:
here's what that portion of the class now reads: { What
could be the cause of that ??? } THANKS

<snip>

Use the "XmlIgnore" attribute on the field. The XmlIgnore attribute
refers to XML serialization, whereas the NonSerialized attribute refers to
binary serialization.

Regards,
Dan
Nov 15 '05 #5
Thanks - I tested that and it worked:
[XmlIgnoreAttribute]
public string disknum;
-----Original Message-----
Hi Andrew,

"andrewcw" <an************@boeing.com> wrote in message
news:23*****************************@phx.gbl...

Kevin, something is not right, I modified the class file and it wrote out the fields and read them back in:
here's what that portion of the class now reads: { What
could be the cause of that ??? } THANKS<snip>

Use the "XmlIgnore" attribute on the field. The

XmlIgnore attributerefers to XML serialization, whereas the NonSerialized attribute refers tobinary serialization.

Regards,
Dan
.

Nov 15 '05 #6
Thanks, Daniel.

Andrew, apologize for my mistake.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: "andrewcw" <an************@boeing.com>
| Sender: "andrewcw" <an************@boeing.com>
| References: <00****************************@phx.gbl>
<MP**************@cpmsftngxa06.phx.gbl>
<23*****************************@phx.gbl>
<OV**************@TK2MSFTNGP12.phx.gbl>
| Subject: Re: mixed XML serialization
| Date: Mon, 6 Oct 2003 11:23:07 -0700
| Lines: 29
| Message-ID: <05****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOMNuQWrsIp/RrBSv6Q4v3XXQ5FIg==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:189332
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thanks - I tested that and it worked:
| [XmlIgnoreAttribute]
| public string disknum;
|
| >-----Original Message-----
| >Hi Andrew,
| >
| >"andrewcw" <an************@boeing.com> wrote in message
| >news:23*****************************@phx.gbl...
| >>
| >> Kevin, something is not right, I modified the class
| file
| >> and it wrote out the fields and read them back in:
| >> here's what that portion of the class now reads: { What
| >> could be the cause of that ??? } THANKS
| ><snip>
| >
| > Use the "XmlIgnore" attribute on the field. The
| XmlIgnore attribute
| >refers to XML serialization, whereas the NonSerialized
| attribute refers to
| >binary serialization.
| >
| >Regards,
| >Dan
| >
| >
| >.
| >
|

Nov 15 '05 #7

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

Similar topics

3
by: Perttu Pulkkinen | last post by:
No questions, but just consider if this is useful to you:-) but of course feedback & corrections are welcome. function php_mixed_to_js_value($jsname, $mixed) { if(is_null($mixed)) { return "\n...
0
by: andrewcw | last post by:
I have an object that serializes back and forth. I would like to have some objects not serialize ..and when I read that info back into the class, have this item be null ( or something like it ). ...
3
by: Aaron Clamage | last post by:
Hi, I'm not sure that if this is the right forum, but any help would be greatly appreciated. I am porting some java serialization code to c# and I can't figure out the correct way to do it. ...
9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
1
by: Bern McCarty | last post by:
I know how with VC8 you embed your linker generated manifest into an exe with a resource ID of #1 and into a dll with resource ID #2. But what do you do with the linker generated manifest for a...
1
by: andrew_nuss | last post by:
Hi, Lets say I have a MIXED tag in my XML DTD with content that is going to be rendered as HMTL, as well as a <boldand <italicstag. What about whitespace? Specifically, does the whitespace in...
1
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
2
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.