Hello Guys, I have tried to use the xsd.exe tool to generate a class for the following Oracle-generated xml sample but always fail to get it right when I try to change oracle xml elements names to the class's names, specifically I'm not sure how to do it for the ROWSET and ROW part of it.
Being very new to the serialization/deserialization business I'm sure this is very easy to implement for someone with a bit of more knowledge of it, can some help me please.
I have created 2 classes for for Department and Employee:
[XmlRoot("ROWSET")]
class Department
{
[XmlElement("DEPARTMENT_ID")]
string DepID { set; get; }
[XmlElement("DEPARTMENT_NAME")]
string DepName { set; get; }
[XmlElement("EMPLOYEES")]
Employee[] Employees { set; get; }
}
class Employee
{
[XmlElement("EMP_ID")]
string DepID { set; get; }
[XmlElement("EMP_NAME")]
string DepName { set; get; }
}
But this fails to work, on runtime it complains it cannot find the ROW element, which to be honest I don't know how to tell in the code to ignore it and start with the next node. I know xsd.exe would help me but it generates lots of unwanted data plus leaves me to sort the names manually. I would really like to learn how to do this without relying on an automation tool.
Many thanks,
Maya
<?xml version="1.0"?>
<ROWSET>
<ROW>
<DEPARTMENT_ID>1</DEPARTMENT_ID>
<DEPARTMENT_NAME>Sales</DEPARTMENT_NAME>
<EMPLOYEES>
<EMP>
<EMP_ID>12</EMP_ID>
<EMP_NAME>Fred</EMP_NAME>
</EMP>
<EMP>
<EMP_ID>13</EMP_ID>
<EMP_NAME>Hohn</EMP_NAME>
</EMP>
</EMPLOYEES>
</ROW>
<ROW>
<DEPARTMENT_ID>2</DEPARTMENT_ID>
<DEPARTMENT_NAME>Marketing</DEPARTMENT_NAME>
<EMPLOYEES></EMPLOYEES>
</ROW>
</ROWSET>