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

related to XMLSerialization

Hi

While i'm doing XML serialization in C# class.... I have the following
problem...

I have an class by name "Operation"

In that i have two variables Id and Name and one more enum variable Mode...
Mode has got values { Manual , Automatic }

I am able to make Id and Name variable as XML Attribute...

I want the mode should be represented as

either <Mode><Automatic/></Mode> or

<Mode><Manual/></Mode>

The Operation object should get serialized as

<Operation Id="Operation1" Name="ship">
<Description>Ship from stock or production</Description>
<Mode>
<Automatic/>
</Mode>
</Operation>

My code looks like

public enum ModeEnum {Manual,Automatic}

public class WFActivity : WFProperty
{
private string _id;
private string _name;
private string _description;
private ModeEnum modeenum;

[XmlAttribute("Id")]
/* sets or gets id */
public string Id
{
get
{
return _id;
}
set
{
_id = value;
}
}

[XmlAttribute("Name")]
/* sets or gets name */
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}

[XmlElement("Description")]
/* sets or gets description */
public string Description
{
get
{
return _description;
}
set
{
_description = value;
}
}
}

Pls throw some light on this.

Thanks in Advance
Keshav
Nov 15 '05 #1
1 1217

Hi Keshav!
While i'm doing XML serialization in C# class.... I have the following
problem...

I have an class by name "Operation"

In that i have two variables Id and Name and one more enum variable Mode... Mode has got values { Manual , Automatic }

I am able to make Id and Name variable as XML Attribute...

I want the mode should be represented as

either <Mode><Automatic/></Mode> or

<Mode><Manual/></Mode>

The Operation object should get serialized as

<Operation Id="Operation1" Name="ship">
<Description>Ship from stock or production</Description>
<Mode>
<Automatic/>
</Mode>
</Operation>

My code looks like

public enum ModeEnum {Manual,Automatic}

public class WFActivity : WFProperty
{
private string _id;
private string _name;
private string _description;
private ModeEnum modeenum;
[skip...]
Pls throw some light on this.


[XmlElement("Mode")]
public ModeType Mode = new ModeType();
public class ModeType
{
ModeEnum _modeenum;
[XmlChoiceIdentifier("Value")]
[XmlElement("Manual")]
[XmlElement("Automatic")]
public string qq = "";
[XmlIgnore]
public ModeEnum Value
{
get
{
return _modeenum;
}
set
{
_modeenum = value;
}
}
}
--
Roman S. Golubin
ICQ UIN 63253392
go*****************@arhcity.ru
Nov 15 '05 #2

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

Similar topics

0
by: Omkar Singh | last post by:
When I serialize my class using XmlSerialization.serialize, it make a lot of reference in the output document. Is there any way to off XmlSerialiation class to make references.
0
by: Omkar Singh | last post by:
I am using XmlSerialization and XmlDeserialization for making soap Body part. Then I am making sopa-header and other part of soap envelope manually. At last joining all part to get complete soap...
0
by: Omkar Singh | last post by:
I have a problem while using XmlSerialization. XmlSerializaion creates a lot of 'href' and namespaces while serializing a complex object. Can we control serialization to stop href and namespaces. ...
2
by: STom | last post by:
I have just started reading up on XMLSerialization and still do not understand the practical use of this technology. For example, if I have to know the class type on the client and on the web...
0
by: HakonB | last post by:
Hi all I get an exception when trying to deserialize a simple configuration file using XML Serialization. The very long stacktrace can be seen at the bottom of this message. I've see other...
0
by: A programmer desperatly needing help! | last post by:
I use the xmlserialization on asp.net pages and on previous machines it never gave a problem. But now i somethings get a: Timed out waiting for a program to execute. The command being executed was...
4
by: pfrisbie | last post by:
I am developing a Web Services interface with C# and our partner is using Java (Axis 1.1). They require me to include xsi:types in the SOAP Messages I send them. For example: <Partner...
3
by: LW | last post by:
Hi! I am getting the following error message for my fairly simple web service. I have classes and have two DataSets that reference the same classes. The error is: The XML element named...
1
by: Frank | last post by:
Hi, Let's say I have a file named myFile.xml Within that file I have blocks of data which I'd like to add at different times during the day. e.g. <LogEntry>
0
by: IanWright | last post by:
This is a little bit more of an advanced topic for serialization. For those who don't know what XML serialization is, then this probably isn't for you just yet. For those that do, you may have come...
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:
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.