ArrayList XmlSerialization Question


R

Raed Sawalha

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
 
Ad

Advertisements


Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top