473,479 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2011
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
2556
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
289
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
3150
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
2564
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
2292
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
1554
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
1566
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
11039
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
2
5524
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
7019
Oralloy
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,...
0
7067
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...
0
6847
tracyyun
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...
0
5312
agi2029
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,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
555
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.