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 6124419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:07:50+00:00 2026-05-23T16:07:50+00:00

Let’s say I have the following class structure (simplified from my real-world problem): Public

  • 0

Let’s say I have the following class structure (simplified from my real-world problem):

Public Class PC_People_Container
    Private _people_list As New List(Of PL_Person)

    Public Sub New()
    End Sub

    Public Sub Add(ByVal item As PL_Person)
        _people_list.Add(item)
    End Sub

    Public Property PeopleList As List(Of PL_Person)
        Get
            Return _people_list
        End Get
        Set(ByVal value As List(Of PL_Person))
            _people_list = value
        End Set
    End Property

End Class

Public Class PL_Person
    Private _Name As String
    Public Property Name As String
        Get
            Return _Name
        End Get
        Set(ByVal value As String)
            _Name = value
        End Set
    End Property

    Private _Contacts As ContactObject
    Public Property Contacts As ContactObject
        Get
            Return _Contacts
        End Get
        Set(ByVal value As ContactObject)
            _Contacts = value
        End Set
    End Property

    Public Sub New()
    End Sub

End Class

Public Class ContactObject
    Public Property PhoneNumber As String
    Public Property EmailAddress As String

    Public Sub New()
    End Sub
End Class

If I were to serialize this, I’d get the default assigned node names in my XML. That means my root is named PC_People_Container and each person in the list is marked up as PL_Person. I know I can change the root node using <XmlRoot(ElementName:="PeopleContainer")>. The trouble is doing that for the subclasses. I can’t use the <XmlRoot> tag on PL_Person class because there can’t be two root elements, and IntelliSense throws a fit when I try to use the <XmlElement> tag on a class like I would on a property. Is it even possible to control what those subclasses are named when they’re serialized as child nodes?

  • 1 1 Answer
  • 1 View
  • 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-23T16:07:51+00:00Added an answer on May 23, 2026 at 4:07 pm

    PL_Person and ContactObject are not subclasses as you call them, they are merely property types.
    This makes your question confusing because it suggests you may have a problem with inheritance (subclasses are classes that inherit from some base class) when in fact you just want your property elements to be named differently.

    You should decorate your properties (not classes) with <XmlElement> to specify custom name:

    <XmlElement("Persons", GetType(PL_Person))>
    Public Property PeopleList As List(Of PL_Person)
    

    As an afterthought, I would definitely not recommend calling your classes using such an awkward convention. In .NET, you should not use any prefixes or underscores in class names. Just call it Person.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following structure: abstract class Hand {} class Rock extends
Let's say I have the following entity: public class Store { public List<Product> Products
Let's say I have a domain object with the following field: private Map<StatType, Double>
Let's say that I have classes like this: public class Parent { public int
Let's say I have following HTML: <span> <span id=x1 class=x>X1</span> </span> <span> <span> <span
Let me explain best with an example. Say you have node class that can
Let's say I have a custom class CustomClass, and I have a collection deriving
Let's say I have the following data frame: > myvec name order_no 1 Amy
let's say I have the following string: string s = A B C D
Let's say I have one class User, and it has a property of type

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.