473,569 Members | 2,453 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("n umber")]
public int Number
{
get
{
return _number;
}
}

}
2)How do I change the element name of a class?
I tried [XMLAttribute("P art")
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 1302
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

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

If the above doesnt work, try putting the following

[XmlRootAttribut e(Namespace="ht tp://www.cpandl.com" ,
ElementName = "Part", Form = XmlSchemaForm.Q ualified,
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("n umber")]
public int Number
{
get
{
return _number;
}
}

}
2)How do I change the element name of a class?
I tried [XMLAttribute("P art")
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-----

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

If the above doesnt work, try putting the following

[XmlRootAttribut e(Namespace="ht tp://www.cpandl.com" ,
ElementName = "Part", Form = XmlSchemaForm.Q ualified,
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("n umber")]
public int Number
{
get
{
return _number;
}
}

}
2)How do I change the element name of a class?
I tried [XMLAttribute("P art")
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
2436
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 UML, and using automatic code generation to make Python APIs, XML I/O etc. (more below). We can be found at http://www.ccpn.ac.uk/index.html As a...
6
5466
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 didn't help. I couldn't find anything about it in the docs so if anybody could help with this it would be great. Kind regards, Gert
1
4030
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 I don´t see any activity regarding auto runstats. Also, the field STATS_TIME from syscat.tables shows that all my table statistics were last...
58
4611
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 the overhead of automatic variable sized arrays, I suspect it is smaller than that of malloc), although I'm not too worried about it. I was...
3
6304
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 created for a period of time? Thanks in advance,
4
4812
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 = 0 Name = SYSCATSPACE Type = Database managed space Tablespace ID ...
3
4636
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 automatic storage on all tablespaces. DB2 Manual says it once AS is enabled, it cant be changed. Is there any way to disable the AS or any other...
3
7498
by: Justin | last post by:
What is the difference between automatic and DMS Auto-resize tablespace?
25
2634
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
3807
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 let you 'assume' a certain schema... Cheers and thanks, -jB
0
7703
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2116
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 we have to send another system
0
944
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.