473,508 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automatic XMLSerializing

Hi,

This is a two part question:

1)trying to serialize a read only class member. I have a
public property with a get statement, but not set, hence
read only. When I serialize the class, this property is
omitted. Can I serialze a public read-only member?

Code segment:
public class Page
{
private static int _number = 0;
[XmlAttribute("number")]
public int Number
{
get
{
return _number;
}
}

}
2)How do I change the element name of a class?
I tried [XMLAttribute("Part")
public class SectionPart
{
}

but the compiler complained stating I couldn't do this.
I wan't the serialization to change the <SectionPart>
element to <Part>

How is this done?

Thanks a lot

Nov 12 '05 #1
4 1298
hi,

Re 1: No You cannot serialize Read-Only properties.

Re 2: You cannot apply the XmlAttribute to a class. It can only be applied
to class members.

Regards,
Akila
[MVP]
Nov 12 '05 #2

If I use custom serialization, can these things be done?
-----Original Message-----
hi,

Re 1: No You cannot serialize Read-Only properties.

Re 2: You cannot apply the XmlAttribute to a class. It can only be appliedto class members.

Regards,
Akila
[MVP]
.

Nov 12 '05 #3

[XmlRootAttribute(ElementName = "Part")]
public class SelectionPart
{
....
}

If the above doesnt work, try putting the following

[XmlRootAttribute(Namespace="http://www.cpandl.com",
ElementName = "Part", Form = XmlSchemaForm.Qualified,
IsNullable = false)]
public class SelectionPart
{
....
}

HTH
Kalpesh

Hman wrote:
Hi,

This is a two part question:

1)trying to serialize a read only class member. I have a
public property with a get statement, but not set, hence
read only. When I serialize the class, this property is
omitted. Can I serialze a public read-only member?

Code segment:
public class Page
{
private static int _number = 0;
[XmlAttribute("number")]
public int Number
{
get
{
return _number;
}
}

}
2)How do I change the element name of a class?
I tried [XMLAttribute("Part")
public class SectionPart
{
}

but the compiler complained stating I couldn't do this.
I wan't the serialization to change the <SectionPart>
element to <Part>

How is this done?

Thanks a lot

Nov 12 '05 #4

Thanks for your response. What you recommended does not
work. I already have a [XmlRoot("Survey")] attribute
defined for class Survey.

Any other ideas?

Thanks
-----Original Message-----

[XmlRootAttribute(ElementName = "Part")]
public class SelectionPart
{
....
}

If the above doesnt work, try putting the following

[XmlRootAttribute(Namespace="http://www.cpandl.com",
ElementName = "Part", Form = XmlSchemaForm.Qualified,
IsNullable = false)]
public class SelectionPart
{
....
}

HTH
Kalpesh

Hman wrote:
Hi,

This is a two part question:

1)trying to serialize a read only class member. I have a public property with a get statement, but not set, hence read only. When I serialize the class, this property is omitted. Can I serialze a public read-only member?

Code segment:
public class Page
{
private static int _number = 0;
[XmlAttribute("number")]
public int Number
{
get
{
return _number;
}
}

}
2)How do I change the element name of a class?
I tried [XMLAttribute("Part")
public class SectionPart
{
}

but the compiler complained stating I couldn't do this.
I wan't the serialization to change the <SectionPart>
element to <Part>

How is this done?

Thanks a lot

.

Nov 12 '05 #5

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

Similar topics

0
2431
by: Rasmus Fogh | last post by:
Someone raised the question of automatic code generation a few weeks back. And yes, we (CCPN) are using automatic Python code generation in a major way. Basically we are making data models in...
6
5455
by: Gert van der Kooij | last post by:
Hi, It's no problem to define the automatic maintenance using the wizard but I want to use commands to automate automation. I captured the SQL statements when activating the maintenance but that...
1
4010
by: Michel Esber | last post by:
Hello, Linux RedHat AS4 running DB2 V8 FP11. I have followed the docs at http://tinyurl.com/qckrn and enabled automatic statistics collection. It has been 2 days since I updated my DB cfg and...
58
4608
by: Jorge Peixoto de Morais Neto | last post by:
I was reading the code of FFmpeg and it seems that they use malloc just too much. The problems and dangers of malloc are widely known. Malloc also has some overhead (although I don't know what is...
3
6297
by: Laurence | last post by:
Hi folks, DB2 UDB supports automatic storage management in v8.2.2 and v9. The question is how do I know the databases and/or tablespaces are enable "automatic storage management" or not after...
4
4811
by: beena | last post by:
All, I'm new to the concept of automatic storage... I'm looking at the database setup by a vendor. I see few tablespaces showing up with automatic storage - Yes. Tablespace ID ...
3
4622
by: myjish18 | last post by:
Hello, We have a DB2 UDB database v8.2.7 (db2 v8.2 fixpak 14) on AIX 5.3 which has Automatic Storage (AS) enabled. We want to disable automatic storage on entire database and/or disable...
3
7494
by: Justin | last post by:
What is the difference between automatic and DMS Auto-resize tablespace?
25
2623
by: sidd | last post by:
In the following code: int i = 5; ---it goes to .data segment int j; ---it goes to bss segment int main() { int c; int i = 5; ---stack
4
3804
by: Joerg Battermann | last post by:
Hello there, does anyone know the precise naming conventions used for internal backing fields for automatic properties? Something official besides looking at the compiled assemblies that might...
0
7383
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
7498
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
5627
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
5053
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
3194
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
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
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
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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.