473,800 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

serializing List<List<strin g>>

Hi,

I am trying to serialize List<List<strin g>.

With the following code

[XmlArrayItem("D ataRow")]
[XmlArray("DataR ows")]
public List<List<strin g>DataRows { get; set; }
I get the following

<DataRows>
<DataRow>
<string>123</string>
<string>432</string>
<string>423</string>
</DataRow>
<DataRow>
<string>4543</string>
<string>53</string>
<string>533</string>
</DataRow>
</DataRows>
I want the output to have <DataRowItemins tead of <string>.

One way it mite work is
if I "box" List<stringas SomeList and then have List<SomeList>. .But
there should be an easier way.

TIA
Jun 27 '08 #1
4 3955
On Apr 22, 11:22 am, parez <psaw...@gmail. comwrote:
Hi,

I am trying to serialize List<List<strin g>.

With the following code

[XmlArrayItem("D ataRow")]
[XmlArray("DataR ows")]
public List<List<strin g>DataRows { get; set; }

I get the following

<DataRows>
<DataRow>
<string>123</string>
<string>432</string>
<string>423</string>
</DataRow>
<DataRow>
<string>4543</string>
<string>53</string>
<string>533</string>
</DataRow>
</DataRows>

I want the output to have <DataRowItemins tead of <string>.

One way it mite work is
if I "box" List<stringas SomeList and then have List<SomeList>. .But
there should be an easier way.

TIA
That didnt work...
I tried
[XmlArrayItem("D ataRow",typeof( Datarow))]
[XmlArray("DataR ows")]
public List<DatarowDat aRows { get; set; }


public class Datarow
{
public Datarow()
{
DataRow = new List<string>();
}
[XmlArrayItem("D ataRowItems")]

public List<stringData Row { get; set; }
}

and this is what i got..

<DataRows>
<DataRow>
<DataRow>
<DataRowItems>1 23</DataRowItems>
<DataRowItems>4 32</DataRowItems>
<DataRowItems>4 23</DataRowItems>
</DataRow>
</DataRow>
<DataRow>
<DataRow>
<DataRowItems>4 543</DataRowItems>
<DataRowItems>5 3</DataRowItems>
<DataRowItems>5 33</DataRowItems>
</DataRow>
</DataRow>
</DataRows>

any one..
Jun 27 '08 #2
On Apr 22, 1:12 pm, parez <psaw...@gmail. comwrote:
On Apr 22, 11:22 am, parez <psaw...@gmail. comwrote:
Hi,
I am trying to serialize List<List<strin g>.
With the following code
[XmlArrayItem("D ataRow")]
[XmlArray("DataR ows")]
public List<List<strin g>DataRows { get; set; }
I get the following
<DataRows>
<DataRow>
<string>123</string>
<string>432</string>
<string>423</string>
</DataRow>
<DataRow>
<string>4543</string>
<string>53</string>
<string>533</string>
</DataRow>
</DataRows>
I want the output to have <DataRowItemins tead of <string>.
One way it mite work is
if I "box" List<stringas SomeList and then have List<SomeList>. .But
there should be an easier way.
TIA

That didnt work...

I tried
[XmlArrayItem("D ataRow",typeof( Datarow))]
[XmlArray("DataR ows")]
public List<DatarowDat aRows { get; set; }

public class Datarow
{
public Datarow()
{
DataRow = new List<string>();
}
[XmlArrayItem("D ataRowItems")]

public List<stringData Row { get; set; }
}

and this is what i got..

<DataRows>
<DataRow>
<DataRow>
<DataRowItems>1 23</DataRowItems>
<DataRowItems>4 32</DataRowItems>
<DataRowItems>4 23</DataRowItems>
</DataRow>
</DataRow>
<DataRow>
<DataRow>
<DataRowItems>4 543</DataRowItems>
<DataRowItems>5 3</DataRowItems>
<DataRowItems>5 33</DataRowItems>
</DataRow>
</DataRow>
</DataRows>

any one..
Any body.. somebody..
Jun 27 '08 #3
On Tue, 22 Apr 2008 15:15:20 -0700, parez <ps*****@gmail. comwrote:
[...]
Any body.. somebody..
For what it's worth, 3 hours since the last post isn't really enough time
for there to be any sense in being impatient.

As for the actual question, I'm no expert in serialization, but it may be
that you simply can't do what you want using only the XmlSerializatio n
attributes. If not, it is actually not that hard to implement
ISerializable so that you have more control over the output.

One possible option would be to make your collection a
List<List<DataR owItem>>, using the default behavior for that property, but
implementing ISerializable on the (newly defined) DataRowItem class such
that it will serialize as "<DataRowItem>x xxx</DataRowItem>".

Pete
Jun 27 '08 #4
On Apr 22, 6:47 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Tue, 22 Apr 2008 15:15:20 -0700, parez <psaw...@gmail. comwrote:
[...]
Any body.. somebody..

For what it's worth, 3 hours since the last post isn't really enough time
for there to be any sense in being impatient.

As for the actual question, I'm no expert in serialization, but it may be
that you simply can't do what you want using only the XmlSerializatio n
attributes. If not, it is actually not that hard to implement
ISerializable so that you have more control over the output.

One possible option would be to make your collection a
List<List<DataR owItem>>, using the default behavior for that property, but
implementing ISerializable on the (newly defined) DataRowItem class such
that it will serialize as "<DataRowItem>x xxx</DataRowItem>".

Pete
Thanks..

i gave up on it..

i am going to go with

<DataRows>
<DataRow>
<string>123</string>
<string>432</string>
<string>423</string>
</DataRow>
<DataRow>
<string>4543</string>
<string>53</string>
<string>533</string>
</DataRow>
</DataRows>

I am going to ask the server guys to change the xml... they owe me
one.. actually a lot...

Jun 27 '08 #5

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

Similar topics

2
2529
by: gbgbgbgb | last post by:
Hi, I have a definition bool operator<(string s_s, string s_t) { .... } and a variable list<string> concomp;
2
5076
by: s | last post by:
I'm getting compile errors on the following code: <code> #include <iostream> #include <fstream> #include <list> #include <string> using namespace std;
3
8496
by: aquanutz | last post by:
Ok, I have a list of strings (list<string> stringList) that I want to sort alphabetcially, only "sort(stringList.begin(), stringList.end()); ) does not work. Any insight would be helpful. Thanks!
3
15184
by: Abhi | last post by:
In the following hypothetical example I want to build a generic list of unique string items. How should I implement the pred function so that it returns true/false if target string exists in the generic list...is not clear to me. Any suggestions? System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(); foreach(string s in myAnotherArray)
6
46193
by: buzzweetman | last post by:
Many times I have a Dictionary<string, SomeTypeand need to get the list of keys out of it as a List<string>, to pass to a another method that expects a List<string>. I often do the following: <BEGIN CODE> List<stringkeyNameList = new List<string>(); foreach (string keyName in this.myDictionary.Keys)
4
23972
by: Mark Rae | last post by:
Hi, Is it possible to create a case-insensitive List<stringcollection? E.g. List<stringMyList = new List<string>; MyList.Add("MyString"); So that:
4
2959
by: rsa_net_newbie | last post by:
Hi there, I have a Managed C++ object (in a DLL) which has a method that is defined like ... Generic::List<String^>^ buildList(String^ inParm) Now, when I compile it, I get "warning C4172: returning address of local variable or temporary". In good old 'C', that would indicate that a 'static' was missing from the declaration of the returned value.
2
5901
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the dictionary essentially creates the following array: Key Value
3
3455
by: banangroda | last post by:
Compilation fails at "line.insert(line.end(), x.begin(), i);" and I can't figure out why. Here is the code: /* 5-1. Design and implement a program to produce a permuted index. A permuted index is one in which each phrase is indexed by every word in the phrase. */
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10251
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7576
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5469
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.