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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:08:08+00:00 2026-05-30T11:08:08+00:00

I have a class that I want to serialize [System.Xml.Serialization.XmlTypeAttribute(Namespace = http://xyz.com/schema)] public class

  • 0

I have a class that I want to serialize

[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://xyz.com/schema")]
public class Customer
{
    [System.Xml.Serialization.XmlElementAttribute(Order = 0)]
    public int Id { get; set; }

    [System.Xml.Serialization.XmlElementAttribute(Order = 1)]
    public string Name { get; set; }

    [System.Xml.Serialization.XmlElementAttribute(Order = 2)]
    public string Url{ get; set; }

    [System.Xml.Serialization.XmlElementAttribute(Order = 3)]
    public string Count { get; set; }
}

When deserializing if Url is null then the out XML does not contain Url Node.
How can mark it as a required field so that Url node gets created everytime?

  • 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-30T11:08:09+00:00Added an answer on May 30, 2026 at 11:08 am

    The IsNullable attribute should do it.

     [System.Xml.Serialization.XmlElementAttribute(Order = 2,IsNullable=true)]
    

    If its set to true, it should generate the tag (According to MSDN).

    If the IsNullable property is set to true, the xsi:nil attribute is
    generated for class members that have been set to a null reference
    (Nothing in Visual Basic). For example if you set a field named
    MyStringArray to a null reference (Nothing in Visual Basic), the
    XmlSerializer generates the following XML code.

    <MyStringArray xsi:nil = "true" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class in .NET that implements IXmlSerializable. I want to serialize its
I have a settings class that I want to be able to serialize and
I want to XML-Serialize a complex type (class), that has a property of type
I have this class: using System; using System.Collections.Generic; using System.Runtime.Serialization; namespace Grouping { [Serializable]
I have a collection that I want to serialize to an xml document. The
Consider the following. You have a class that you want to serialize with XmlSerializer
I have a class that I want to use to store properties for another
I have a class that i want to push_back into a deque. The problem
I have a class that I want to include in a GWT module. Unfortunately,
Suppose I have a Python class that I want to add an extra property

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.