473,408 Members | 2,839 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,408 software developers and data experts.

Serializing an XmlArray with attributes

Hi

I'm currently having trouble serializing an object to Xml, in the format I
need.
Below is the object definition.

-------------------------------
[Serializable]
public class Folders
{
protected List<PathString_include;
protected List<PathString_exclude;

public Folders()
{
_include = new List<PathString>();
_exclude = new List<PathString>();
}

[XmlArrayItem("Include")]
public List<PathStringInclude
{
get { return _include; }
set { _include = value; }
}

[XmlArrayItem(ElementName="Exclude",Type=typeof(Pat hString))]
public List<PathStringExcludes
{
get { return _exclude; }
set { _exclude = value; }
}
}

[Serializable]
public class PathString
{
protected string _path;

[XmlAttribute]
public string Path
{
get { return _path; }
set { _path = value; }
}

public PathString()
{
}

public PathString(string path)
{
_path = path;
}
}
--------------------------

From these objects, I want my Xml output to look like :

<Folders>
<Include Path="Path1"/>
<Include Path="Path2"/>
<Exclude Path="LessTrodden"/>
</Folders>

However, I am having trouble getting the correct output.
The code above produces the following :

<Folders>
<Include>
<Include Path="Path1"/>
<Include Path="Path2"/>
</Include>
<Excludes>
<Exclude Path="LessTrodden"/>
</Excludes>
</Folders>

I want to use List (or IList) as I want to bind my object to a DevExpress
TreeList
Does anyone have an idea of how I can get my required output ?

Cheers

Ged

Jul 31 '07 #1
0 3231

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

Similar topics

1
by: Waz | last post by:
I'm having some problems serializing a class that contains a collection. Creating the TestClass below and then calling its Serialize method throws the error: There was an error reflecting...
4
by: Angelos Karantzalis | last post by:
Hi guys. I've come across a problem when I tried to serialize a class into xml, only to discover that the parent class's XML Serialization properties weren't included in the output xml. ...
4
by: Christopher Pragash | last post by:
Hello all, Following is the code that I'm using to serialize an arraylist. This code returns an "Unknown" Errror. Any ideas would be of great help. <System.Xml.Serialization.XmlArray(), _...
3
by: Daniel Lidström | last post by:
Hello, I want to have a class that contains only a collection of another class. For example: public __gc class Alignment { public: Alignment(); ... };
2
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from...
0
by: Ante Smolcic | last post by:
Hi all, I have an ArrayList that contains items of type A. I declared the XmlArrayItem atribute for that type. Now I have an derived type B (from A) also contained in the ArrayList but I get...
4
by: Wayne Wengert | last post by:
I am still stuck trying to create a Class to use for exporting and importing array data to/from XML. The format of the XML that I want to import/export is shown below as is the Class and the code I...
0
by: dph5010 | last post by:
I'm trying to make an object that will reflect the response from isbndb.com's API so I can serialize the results into my code. Right now I have code that works, however, the structure isn't quite the...
4
by: parez | last post by:
Hi, I am trying to serialize List<List<string>. With the following code public List<List<string>DataRows { get; set; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...
0
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...
0
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...

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.