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

question about xml serilization

hello,

This is my sample (simplified):

public class Binom
{
[XmlAttribute("range")]
public string _Value;

[XmlAttribute("name")]
public string Label;
}

public class Property
{
[XmlAttribute("name")]
public string propertyName;

public Binom DefaultAttribute;
}
Property serialize as:

<Properties name="foo">
<DefaultAttribute value="123456789" name="range" />
</Properties >

Is is possible to get rather:

<foo range="123456789"/>

or eventualy:

<Properties name="foo">
<DefaultAttribute range="123456789" />
</Properties >

Just using the default Xml serailization?

Thank you

Happy new years
Nov 12 '05 #1
6 2806

amethyste,

are you trying to dynamically set the element name based on values in
your object, i.e. if the propertyName is foo and the label is set to
range, then the serialized XML is

<foo range="..." />?

First, changing the element name is only possible if you have a fixed
set of element names, but not if propertyName can hold arbitrary
strings. XML serialization is intended to be used with
strongly-structured XML data. Therefore it works best if you can express
the XML format as an XML Schema. You can change the element names either
based on the type of the serialized object:

[XmlElement( "foo", typeof(fooType))]
[XmlElement( "bar", typeof(barType))]
public foobarType propertyName;

or by using the choice construct [0].

Second, changing the attribute name dynamically only works based on the
type of the serialized type via attaching multiple attributes. There is
no equivalent to the choice construct for attributes.

If you need to be able to by more dynamic than that you must implement
IXmlSerializable [1].

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

[0] http://www.topxml.com/xmlserializer/...del_groups.asp
[1] http://msdn2.microsoft.com/library/fhd7bk0a.aspx
-----Original Message-----
From: amethyste [mailto:an*******@discussions.microsoft.com]
Posted At: Tuesday, December 28, 2004 7:16 AM
Posted To: microsoft.public.dotnet.xml
Conversation: question about xml serilization
Subject: question about xml serilization

hello,

This is my sample (simplified):

public class Binom
{
[XmlAttribute("range")]
public string _Value;

[XmlAttribute("name")]
public string Label;
}

public class Property
{
[XmlAttribute("name")]
public string propertyName;

public Binom DefaultAttribute;
}
Property serialize as:

<Properties name="foo">
<DefaultAttribute value="123456789" name="range" />
</Properties >

Is is possible to get rather:

<foo range="123456789"/>

or eventualy:

<Properties name="foo">
<DefaultAttribute range="123456789" />
</Properties >

Just using the default Xml serailization?

Thank you

Happy new years


Nov 12 '05 #2
thank you,

I suspected something like this.
I'm in the case where IXmlSerializable is the solution.

But IXmlSerializable is not officially documented. This
wories me a little bit.

-----Original Message-----

amethyste,

are you trying to dynamically set the element name based on values inyour object, i.e. if the propertyName is foo and the label is set torange, then the serialized XML is

<foo range="..." />?

First, changing the element name is only possible if you have a fixedset of element names, but not if propertyName can hold arbitrarystrings. XML serialization is intended to be used with
strongly-structured XML data. Therefore it works best if you can expressthe XML format as an XML Schema. You can change the element names eitherbased on the type of the serialized object:

[XmlElement( "foo", typeof(fooType))]
[XmlElement( "bar", typeof(barType))]
public foobarType propertyName;

or by using the choice construct [0].

Second, changing the attribute name dynamically only works based on thetype of the serialized type via attaching multiple attributes. There isno equivalent to the choice construct for attributes.

If you need to be able to by more dynamic than that you must implementIXmlSerializable [1].

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

[0] http://www.topxml.com/xmlserializer/...odel_groups.as
p[1] http://msdn2.microsoft.com/library/fhd7bk0a.aspx
-----Original Message-----
From: amethyste [mailto:an*******@discussions.microsoft.com] Posted At: Tuesday, December 28, 2004 7:16 AM
Posted To: microsoft.public.dotnet.xml
Conversation: question about xml serilization
Subject: question about xml serilization

hello,

This is my sample (simplified):

public class Binom
{
[XmlAttribute("range")]
public string _Value;

[XmlAttribute("name")]
public string Label;
}

public class Property
{
[XmlAttribute("name")]
public string propertyName;

public Binom DefaultAttribute;
}
Property serialize as:

<Properties name="foo">
<DefaultAttribute value="123456789" name="range" />
</Properties >

Is is possible to get rather:

<foo range="123456789"/>

or eventualy:

<Properties name="foo">
<DefaultAttribute range="123456789" />
</Properties >

Just using the default Xml serailization?

Thank you

Happy new years


.

Nov 12 '05 #3
Hi:

Till .NET 1.1, IXmlSerializable was mostly intended for internal (MS) use.
With 2.0, IXmlSerializable is receiving more publicity and programmers will
be encouraged to use it.
For info about how to implement IXmlSerializable in 1.1:
http://dotnetified.com/PermaLink.asp...F-CDA36ACF481F

Mujtaba.

"amethyste" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
thank you,

I suspected something like this.
I'm in the case where IXmlSerializable is the solution.

But IXmlSerializable is not officially documented. This
wories me a little bit.

-----Original Message-----

amethyste,

are you trying to dynamically set the element name based

on values in
your object, i.e. if the propertyName is foo and the

label is set to
range, then the serialized XML is

<foo range="..." />?

First, changing the element name is only possible if you

have a fixed
set of element names, but not if propertyName can hold

arbitrary
strings. XML serialization is intended to be used with
strongly-structured XML data. Therefore it works best if

you can express
the XML format as an XML Schema. You can change the

element names either
based on the type of the serialized object:

[XmlElement( "foo", typeof(fooType))]
[XmlElement( "bar", typeof(barType))]
public foobarType propertyName;

or by using the choice construct [0].

Second, changing the attribute name dynamically only

works based on the
type of the serialized type via attaching multiple

attributes. There is
no equivalent to the choice construct for attributes.

If you need to be able to by more dynamic than that you

must implement
IXmlSerializable [1].

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

[0]

http://www.topxml.com/xmlserializer/...odel_groups.as
p
[1] http://msdn2.microsoft.com/library/fhd7bk0a.aspx
-----Original Message-----
From: amethyste [mailto:an*******@discussions.microsoft.com] Posted At: Tuesday, December 28, 2004 7:16 AM
Posted To: microsoft.public.dotnet.xml
Conversation: question about xml serilization
Subject: question about xml serilization

hello,

This is my sample (simplified):

public class Binom
{
[XmlAttribute("range")]
public string _Value;

[XmlAttribute("name")]
public string Label;
}

public class Property
{
[XmlAttribute("name")]
public string propertyName;

public Binom DefaultAttribute;
}
Property serialize as:

<Properties name="foo">
<DefaultAttribute value="123456789" name="range" />
</Properties >

Is is possible to get rather:

<foo range="123456789"/>

or eventualy:

<Properties name="foo">
<DefaultAttribute range="123456789" />
</Properties >

Just using the default Xml serailization?

Thank you

Happy new years


.

Nov 12 '05 #4
The .NET 2.0 documentation for IXmlSerializable is also already
available at

http://msdn2.microsoft.com/library/fhd7bk0a.aspx

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

-----Original Message-----
From: Mujtaba Syed [mailto:mu*****@marlabs.com]
Posted At: Tuesday, December 28, 2004 3:53 PM
Posted To: microsoft.public.dotnet.xml
Conversation: question about xml serilization
Subject: Re: question about xml serilization

Hi:

Till .NET 1.1, IXmlSerializable was mostly intended for internal (MS) use. With 2.0, IXmlSerializable is receiving more publicity and programmers
will
be encouraged to use it.
For info about how to implement IXmlSerializable in 1.1:
http://dotnetified.com/PermaLink.asp...A95-49B6-909F-
CDA36ACF481F

Mujtaba.

"amethyste" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
thank you,

I suspected something like this.
I'm in the case where IXmlSerializable is the solution.

But IXmlSerializable is not officially documented. This
wories me a little bit.

-----Original Message-----

amethyste,

are you trying to dynamically set the element name based

on values in
your object, i.e. if the propertyName is foo and the

label is set to
range, then the serialized XML is

<foo range="..." />?

First, changing the element name is only possible if you

have a fixed
set of element names, but not if propertyName can hold

arbitrary
strings. XML serialization is intended to be used with
strongly-structured XML data. Therefore it works best if

you can express
the XML format as an XML Schema. You can change the

element names either
based on the type of the serialized object:

[XmlElement( "foo", typeof(fooType))]
[XmlElement( "bar", typeof(barType))]
public foobarType propertyName;

or by using the choice construct [0].

Second, changing the attribute name dynamically only

works based on the
type of the serialized type via attaching multiple

attributes. There is
no equivalent to the choice construct for attributes.

If you need to be able to by more dynamic than that you

must implement
IXmlSerializable [1].

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

[0]

http://www.topxml.com/xmlserializer/...odel_groups.as
p
[1] http://msdn2.microsoft.com/library/fhd7bk0a.aspx

> -----Original Message-----
> From: amethyste

[mailto:an*******@discussions.microsoft.com]
> Posted At: Tuesday, December 28, 2004 7:16 AM
> Posted To: microsoft.public.dotnet.xml
> Conversation: question about xml serilization
> Subject: question about xml serilization
>
> hello,
>
> This is my sample (simplified):
>
> public class Binom
> {
> [XmlAttribute("range")]
> public string _Value;
>
> [XmlAttribute("name")]
> public string Label;
> }
>
> public class Property
> {
> [XmlAttribute("name")]
> public string propertyName;
>
> public Binom DefaultAttribute;
> }
>
>
> Property serialize as:
>
> <Properties name="foo">
> <DefaultAttribute value="123456789" name="range" />
> </Properties >
>
> Is is possible to get rather:
>
> <foo range="123456789"/>
>
> or eventualy:
>
> <Properties name="foo">
> <DefaultAttribute range="123456789" />
> </Properties >
>
> Just using the default Xml serailization?
>
> Thank you
>
> Happy new years

.

Nov 12 '05 #5
IXmlSerializable is still for internal use in vs 2005
béta, but this time MS gives samples!
I don't understand this anyway, why not fully document
this interface? It's just an interface after all and
runtime serialization has a full support for
customization already.

thank you
Amethyste
-----Original Message-----
Hi:

Till .NET 1.1, IXmlSerializable was mostly intended for internal (MS) use.With 2.0, IXmlSerializable is receiving more publicity and programmers willbe encouraged to use it.
For info about how to implement IXmlSerializable in 1.1:
http://dotnetified.com/PermaLink.asp...E86B447E-AA95- 49B6-909F-CDA36ACF481F
Mujtaba.

"amethyste" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
thank you,

I suspected something like this.
I'm in the case where IXmlSerializable is the solution.

But IXmlSerializable is not officially documented. This
wories me a little bit.

>-----Original Message-----
>
>amethyste,
>
>are you trying to dynamically set the element name
based on values in
>your object, i.e. if the propertyName is foo and the

label is set to
>range, then the serialized XML is
>
><foo range="..." />?
>
>First, changing the element name is only possible if
you have a fixed
>set of element names, but not if propertyName can hold

arbitrary
>strings. XML serialization is intended to be used with
>strongly-structured XML data. Therefore it works best
if you can express
>the XML format as an XML Schema. You can change the

element names either
>based on the type of the serialized object:
>
>[XmlElement( "foo", typeof(fooType))]
>[XmlElement( "bar", typeof(barType))]
>public foobarType propertyName;
>
>or by using the choice construct [0].
>
>Second, changing the attribute name dynamically only

works based on the
>type of the serialized type via attaching multiple

attributes. There is
>no equivalent to the choice construct for attributes.
>
>If you need to be able to by more dynamic than that
you must implement
>IXmlSerializable [1].
>
>HTH,
>Christoph Schittko
>MVP XML
>http://weblogs.asp.net/cschittko
>
>
>
>[0]

http://www.topxml.com/xmlserializer/...odel_groups.as p
>[1] http://msdn2.microsoft.com/library/fhd7bk0a.aspx
>
>> -----Original Message-----
>> From: amethyste

[mailto:an*******@discussions.microsoft.com]
>> Posted At: Tuesday, December 28, 2004 7:16 AM
>> Posted To: microsoft.public.dotnet.xml
>> Conversation: question about xml serilization
>> Subject: question about xml serilization
>>
>> hello,
>>
>> This is my sample (simplified):
>>
>> public class Binom
>> {
>> [XmlAttribute("range")]
>> public string _Value;
>>
>> [XmlAttribute("name")]
>> public string Label;
>> }
>>
>> public class Property
>> {
>> [XmlAttribute("name")]
>> public string propertyName;
>>
>> public Binom DefaultAttribute;
>> }
>>
>>
>> Property serialize as:
>>
>> <Properties name="foo">
>> <DefaultAttribute value="123456789" name="range" />
>> </Properties >
>>
>> Is is possible to get rather:
>>
>> <foo range="123456789"/>
>>
>> or eventualy:
>>
>> <Properties name="foo">
>> <DefaultAttribute range="123456789" />
>> </Properties >
>>
>> Just using the default Xml serailization?
>>
>> Thank you
>>
>> Happy new years
>
>.
>

.

Nov 12 '05 #6
It is not recommeded to use the GetSchema method of IXmlSerialiazable 2.0.
Instead a new attribute called [XmlSchemaProvider] is available to indicate
a static method of the type that will provide the schema.

http://msdn.microsoft.com/library/de...l/wsnetfx2.asp

Mujtaba.

"Christoph Schittko [MVP]" <IN**********@austin.rr.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
The .NET 2.0 documentation for IXmlSerializable is also already
available at

http://msdn2.microsoft.com/library/fhd7bk0a.aspx

HTH,
Christoph Schittko
MVP XML
http://weblogs.asp.net/cschittko

-----Original Message-----
From: Mujtaba Syed [mailto:mu*****@marlabs.com]
Posted At: Tuesday, December 28, 2004 3:53 PM
Posted To: microsoft.public.dotnet.xml
Conversation: question about xml serilization
Subject: Re: question about xml serilization

Hi:

Till .NET 1.1, IXmlSerializable was mostly intended for internal (MS)

use.
With 2.0, IXmlSerializable is receiving more publicity and programmers
will
be encouraged to use it.
For info about how to implement IXmlSerializable in 1.1:
http://dotnetified.com/PermaLink.asp...A95-49B6-909F-
CDA36ACF481F

Mujtaba.

"amethyste" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
thank you,

I suspected something like this.
I'm in the case where IXmlSerializable is the solution.

But IXmlSerializable is not officially documented. This
wories me a little bit.
>-----Original Message-----
>
>amethyste,
>
>are you trying to dynamically set the element name based
on values in
>your object, i.e. if the propertyName is foo and the
label is set to
>range, then the serialized XML is
>
><foo range="..." />?
>
>First, changing the element name is only possible if you
have a fixed
>set of element names, but not if propertyName can hold
arbitrary
>strings. XML serialization is intended to be used with
>strongly-structured XML data. Therefore it works best if
you can express
>the XML format as an XML Schema. You can change the
element names either
>based on the type of the serialized object:
>
>[XmlElement( "foo", typeof(fooType))]
>[XmlElement( "bar", typeof(barType))]
>public foobarType propertyName;
>
>or by using the choice construct [0].
>
>Second, changing the attribute name dynamically only
works based on the
>type of the serialized type via attaching multiple
attributes. There is
>no equivalent to the choice construct for attributes.
>
>If you need to be able to by more dynamic than that you
must implement
>IXmlSerializable [1].
>
>HTH,
>Christoph Schittko
>MVP XML
>http://weblogs.asp.net/cschittko
>
>
>
>[0]
http://www.topxml.com/xmlserializer/...odel_groups.as
p
>[1] http://msdn2.microsoft.com/library/fhd7bk0a.aspx
>
>> -----Original Message-----
>> From: amethyste
[mailto:an*******@discussions.microsoft.com]
>> Posted At: Tuesday, December 28, 2004 7:16 AM
>> Posted To: microsoft.public.dotnet.xml
>> Conversation: question about xml serilization
>> Subject: question about xml serilization
>>
>> hello,
>>
>> This is my sample (simplified):
>>
>> public class Binom
>> {
>> [XmlAttribute("range")]
>> public string _Value;
>>
>> [XmlAttribute("name")]
>> public string Label;
>> }
>>
>> public class Property
>> {
>> [XmlAttribute("name")]
>> public string propertyName;
>>
>> public Binom DefaultAttribute;
>> }
>>
>>
>> Property serialize as:
>>
>> <Properties name="foo">
>> <DefaultAttribute value="123456789" name="range" />
>> </Properties >
>>
>> Is is possible to get rather:
>>
>> <foo range="123456789"/>
>>
>> or eventualy:
>>
>> <Properties name="foo">
>> <DefaultAttribute range="123456789" />
>> </Properties >
>>
>> Just using the default Xml serailization?
>>
>> Thank you
>>
>> Happy new years
>
>.
>


Nov 12 '05 #7

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

Similar topics

3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
3
by: Stephan Schlicker | last post by:
Hi everyone I have a serious problem with the serilization of an user-defined object in C#. I would like to serialize an object of class D which inherits from class C. Class C as well as class D...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
3
by: RJA | last post by:
Hiyas, Using VS .net 2003. Setting up a Webservice that accepts 3rd party vendor designed XML requests and returns a filled XMLDocument with response data. Vendor XSDs were serialize into...
7
by: Mike9900 | last post by:
If you do .NET Remoting and Binary Serilization with DataSet it does not work. If you set the Serialization type to Binary on DataSet, it does not seralize it correctly on windows xp. To do this...
5
by: raj | last post by:
I know what interfaces are and what they used for etc. Today i am learning about serilization. I know to mark the class "serializable" and implement ISerializable interface, and then implement...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.