I have a simple method that is used C# .Net classes to serialize a list of objects to a XML string. For that method, I'd like to remove xml elements from the produced XML string. Please help. Thank you.
My method:
public static string CreateXML(List<Video> list)
{
string result = "";
StringWriter stringWriter = new StringWriter();
XmlSerializer s = new XmlSerializer(list.GetType());
s.Serialize(stringWriter, list);
result = stringWriter.ToString();
return result;
}
The result string (I cut off for brevity) I get from that method:
<?xml version="1.0" encoding="utf-16" ?>
<ArrayOfVideo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Video>-
....
</Video>
<Video>
....
</Video>
</ArrayOfVideo>
I would like to have a result xml string like: (tag is added <Videos> and </Videos>)
<Videos>
<Video>-
....
</Video>
<Video>
....
</Video>
</Videos>
So, I want to remove lines:
<?xml version="1.0" encoding="utf-16" ?>
<ArrayOfVideo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</ArrayOfVideo>