2

i need to create the following in XML:

<DATAITEMS>
  <DATAITEM>ABC</DATAITEM>
  <DATAITEM>1</DATAITEM>
</DATAITEMS>

when i configure my property as:

public List<string> DATAITEMS { get; set; }

this gives me an output of:

<DATAITEMS>
  <string>ABC</string>
  <string>1</string>
</DATAITEMS>

any idea how can i create collection of DATAITEM instead of string?

thanks

2
  • How are you currently converting the list into XML? Commented Feb 3, 2011 at 17:40
  • well are you serializing your class? Commented Feb 3, 2011 at 17:53

1 Answer 1

6

I hope you are trying to serialize your data, if so you have to use XmlArrayItem to control array item names.

 [XmlArray("DATAITEMS")]
 [XmlArrayItem("DATAITEM")]
 public List<string> DATAITEMS { get; set; }
Sign up to request clarification or add additional context in comments.

2 Comments

well i was trying serialization now a days :P.
it would really help other if you can edit your question to answer Cameron's and my question :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.