Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 607635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:22:51+00:00 2026-05-13T17:22:51+00:00

I have tried to use the xsd.exe tool to generate a class for the

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:22:51+00:00Added an answer on May 13, 2026 at 5:22 pm

    You may need to create an additional class Row. Also make sure classes and properties are public. Here’s an example of how to serialize a Department instance to the given XML structure using XmlSerializer:

    [XmlRoot("ROWSET")]
    public class Department
    {
        [XmlElement("ROW")]
        public Row[] Rows { get; set; }
    }
    
    public class Row
    {
        [XmlElement("DEPARTMENT_ID")]
        public string DepID { set; get; }
    
        [XmlElement("DEPARTMENT_NAME")]
        public string DepName { set; get; }
    
        [XmlArray("EMPLOYEES")]
        [XmlArrayItem("EMP")]
        public Employee[] Employees { set; get; }
    }
    
    public class Employee
    {
        [XmlElement("EMP_ID")]
        public string EmpID { set; get; }
    
        [XmlElement("EMP_NAME")]
        public string EmpName { set; get; }
    }
    
    class Program
    {
        static void Main()
        {
            var dep = new Department
            {
                Rows = new[] 
                {
                    new Row 
                    {
                        DepID = "1",
                        DepName = "Sales",
                        Employees = new[] 
                        {
                            new Employee 
                            {
                                EmpID = "12",
                                EmpName = "Fred"
                            },
                            new Employee 
                            {
                                EmpID = "13",
                                EmpName = "Hohn"
                            }
                        }
                    },
                    new Row 
                    {
                        DepID = "2",
                        DepName = "Marketing",
                    }
                }
            };
            var serializer = new XmlSerializer(dep.GetType());
            serializer.Serialize(Console.Out, dep);
        }
    

    And to deserialize back to a Department instance:

    var xml = 
    @"<?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>";
    
    using (var reader = new StringReader(xml))
    {
        var department = (Department)serializer.Deserialize(reader);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to use the following snippet of code: int main() { string
I use maven 3.0.3 and have tried to generate pom for third-party jar like
I have to use oracle database in android. I have tried to work as
I have tried to use findstr and even windows explorer but I can't get
I have a question about how to use XSD Schema to validate XML format.
I have tried to use mysql fulltext search in my intranet. I wanted to
I have heard about JNI and have tried to use it. What I would
Have you tried to use SharePoint with version control such as Perforce (or Subversion),
I want to use a variable in a string. I have tried to do
I have small library i want to use for creating games. First, i tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.