July 01, 2003
Parsing XML Files in .NET Using C#
Listing 8 Modified suite definition
using System;
using System.Xml.Serialization;
namespace SerializerLib
{
[XmlRootAttribute("suite")]
public class Suite
{
[XmlElementAttribute("testcase")]
public TestCase[] items; // changed name from xsd-generated code
public void Display() // added to xsd-generated code
{
foreach (TestCase tc in items)
{
Console.Write(tc.id + " " + tc.kind + " " + tc.inputs.arg1 + " ");
Console.WriteLine(tc.inputs.arg2 + " " + tc.expected);
}
}
}
public class TestCase // changed name from xsd-generated code
{
[XmlAttributeAttribute()]
public string id;
[XmlAttributeAttribute()]
public string kind;
[XmlElementAttribute("inputs")]
public Inputs inputs; // change from xsd-generated code: no array
public string expected;
}
public class Inputs // changed name from xsd-generated code
{
public string arg1;
public string arg2;
}
}
|
|
||||||||||||||||||||||||||||
|
|