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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:19:27+00:00 2026-05-23T23:19:27+00:00

I have BaseClass List Public Class Package <XmlElement(OBJECT)> Public List As List(Of baseobj) Public

  • 0

I have BaseClass List

Public Class Package

  <XmlElement("OBJECT")>
  Public List As List(Of baseobj)
  Public Sub New()
    List = New List(Of baseobj)
    Dim f As New First()
    Dim s As New Second()
    List.Add(s)
    List.Add(f)
  End Sub

  Function Serialize() As String
    Dim XmlSerializer As New XmlSerializer(GetType(Package), "")
    Dim NS As New XmlSerializerNamespaces()
    Dim SB As New StringBuilder
    Dim str As New StringWriter(SB)
    NS.Add("", "")
    XmlSerializer.Serialize(str, Me, NS)
    Return SB.ToString
  End Function
End Class

Base class

<XmlInclude(GetType(First))>
<XmlInclude(GetType(Second))>
Public MustInherit Class baseobj
  Public Common As String
  Public Sub New()
    Common = "_Common"
  End Sub
End Class

And drived classes

Public Class First
  Inherits baseobj
  <XmlAttribute("term")>
  Public FirstAttr As String

  Public Sub New()
    MyBase.New()
    FirstAttr = "FirstAttr"
  End Sub
End Class

Public Class Second
  Inherits baseobj
  <XmlAttribute("term")>
  Public SecAttr As String

  Public Sub New()
    MyBase.New()
    SecAttr = "SecAttr"
  End Sub
End Class

On serializing package object (pkg.Serialize) have this:

<?xml version="1.0" encoding="utf-16"?>
<Package>
  <OBJECT d2p1:type="Second" term="SecAttr" xmlns:d2p1="http://www.w3.org/2001/XMLSchema-instance">
    <Common>_Common</Common>
  </OBJECT>
  <OBJECT d2p1:type="First" term="FirstAttr" xmlns:d2p1="http://www.w3.org/2001/XMLSchema-instance">
    <Common>_Common</Common>
  </OBJECT>
</Package>

How can i serialize package object to

<?xml version="1.0" encoding="utf-16"?>
<Package>
  <OBJECT Type="Second" term="SecAttr" >
    <Common>_Common</Common>
  </OBJECT>
  <OBJECT Type="First" term="FirstAttr">
    <Common>_Common</Common>
  </OBJECT>
</Package>

without namespaces and prefixes

  • 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-23T23:19:28+00:00Added an answer on May 23, 2026 at 11:19 pm

    You can’t do that. Where would the Type attribute come from?

    d2p1:type (usually written as xsi:type) is a well-known attribute used to convey the actual type of an element. If you could get rid of the namespace, then it would be meaningless.

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

Sidebar

Related Questions

I have a Class FileDoc Public Class FileDoc Inherits BaseClass Public Sub DeleteDoc() dim
I have a base class like this: package MyClass; use vars qw/$ME list of
i have an abstract class BaseClass with a public insert() method: public abstract class
I have a UserControl that has a BaseClass object as a public member. Right
I have a class like this: public class BaseClass { public BaseClass(URL url, String
I have this code for example public class BaseClass {} public class DerivedClass1 :
Let's say I have a base class named BaseClass: public BaseClase{ public bool isCool;
I have the following class hierarchy public abstract BaseClass : System.Web.UI.UserControl { public virtual
i have the following classes and mappings abstract class BaseClass { public virtual int
I have base class BaseClass and derived classes DerivedA , DerivedB , and DerivedC

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.