ArrayList XmlSerialization Question

Discussion in 'ASP .Net Web Services' started by Raed Sawalha, Apr 4, 2005.

  1. Raed Sawalha

    Raed Sawalha Guest

    I have the following
    a class with ArrayList member

    [XmlInclude(typeof(keyword))]
    public class Info
    {
    Info(){data = new ArrayList();}

    public ArrayList keyword;
    public void Add(string sData)
    {
    keyword key;
    key = new keyword();
    key.data = sData;
    data.Add(key);
    }
    public string SerializeObject(object oClassObject,System.Type oClassType)
    {
    XmlSerializer oSerializer = new XmlSerializer(oClassType);
    System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
    System.IO.TextWriter writer = new System.IO.StringWriter(strBuilder);
    oSerializer.Serialize(writer,oClassObject);
    return strBuilder.ToString();
    }

    in my aspx page i called
    Info oInfo = new Info();
    oInfo.Add( "Key1 ");
    oInfo.Add( "Key2 ");
    string str = oInfo.SerializeObject(oInfo,typeof(Info));

    after XML Generation in the keyword section i got like this

    - <keyword>
    - <anyType xsi:type="keyword">
    <LangString>key1</LangString>
    </anyType>
    - <anyType xsi:type="keyword">
    <LangString>key2</LangString>
    </anyType>
    </keyword>

    how can I get result like following
    <keyword>
    <LangString>key1</LangString>
    </keyword>
    <keyword>
    <LangString>key2</LangString>
    </keyword>
    each keyword in independent element, is this possible
    Raed Sawalha, Apr 4, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QSBwcm9ncmFtbWVyIGRlc3BlcmF0bHkgbmVlZGlu

    XMLSerialization: Sometimes csc.exe freezes on the PermissionSet

    =?Utf-8?B?QSBwcm9ncmFtbWVyIGRlc3BlcmF0bHkgbmVlZGlu, Nov 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    619
    =?Utf-8?B?QSBwcm9ncmFtbWVyIGRlc3BlcmF0bHkgbmVlZGlu
    Nov 18, 2004
  2. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    XmlSerialization Problem

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Nov 28, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    366
    =?Utf-8?B?UmFlZCBTYXdhbGhh?=
    Nov 28, 2004
  3. No one

    XmlSerialization error

    No one, Jun 17, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    398
    No one
    Jun 18, 2005
  4. =?Utf-8?B?Q2hyaXMgU3phYm8=?=

    XmlSerialization base classes

    =?Utf-8?B?Q2hyaXMgU3phYm8=?=, Jan 19, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    478
    Kevin Spencer
    Jan 20, 2006
  5. Frank
    Replies:
    1
    Views:
    348
    sloan
    Mar 6, 2007
Loading...

Share This Page