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. Advertisements

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. Saravanan Rathinavelu

    Iterate through ArrayList using an another ArrayList

    Saravanan Rathinavelu, Aug 16, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    3,059
    Natty Gur
    Aug 19, 2003
  2. =?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:
    784
    =?Utf-8?B?QSBwcm9ncmFtbWVyIGRlc3BlcmF0bHkgbmVlZGlu
    Nov 18, 2004
  3. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    XmlSerialization Problem

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

    XmlSerialization error

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

    XmlSerialization base classes

    =?Utf-8?B?Q2hyaXMgU3phYm8=?=, Jan 19, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    579
    Kevin Spencer
    Jan 20, 2006
  6. Kaidi
    Replies:
    4
    Views:
    3,080
    Kaidi
    Jan 3, 2004
  7. Frank
    Replies:
    1
    Views:
    443
    sloan
    Mar 6, 2007
  8. getting error at time of XmlSerialization

    , Sep 22, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    191
Loading...