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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:01:34+00:00 2026-06-07T20:01:34+00:00

[XmlRoot(company), DataContract(Name = company)] public class Company : IProvideSerialization { /// <summary> /// Stock

  • 0
[XmlRoot("company"), DataContract(Name = "company")]
public class Company : IProvideSerialization
{
    /// <summary>
    /// Stock exchange the company is in.
    /// </summary>
    /// <see cref="https://developer.linkedin.com/documents/company-lookup-api-and-fields"/>
    /// <remarks>Available only for public companies.</remarks>
    [XmlElement("stock-exchange"), DataMember(Name = "stock-exchange", EmitDefaultValue = false, IsRequired = false), EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
    protected SerializableEnum<StockExchange> StockExchangeForXML;
    public static Company FromXml(String XML)
    {
        XmlSerializer x = new XmlSerializer(typeof(Company));
        return (Company)x.Deserialize(new StringReader(XML));
    }
}

The SerializableEnum implements IXmlSerializable.

SerializableEnum also has a FromXml that works; it looks as followed:

    public static SerializableEnum<T> FromXml(string XML)
    {
        XmlRootAttribute XR = (XmlRootAttribute)System.Attribute.GetCustomAttribute(typeof(T), typeof(XmlRootAttribute));
        XmlSerializer x = new XmlSerializer(typeof(SerializableEnum<T>), new XmlRootAttribute() { ElementName = XR.ElementName, IsNullable = true });
        return (SerializableEnum<T>)x.Deserialize(new StringReader(XML));
    }

When I do:

        String StockXML = "<stock-exchange><code>NMS</code><name>NASDAQ</name></stock-exchange>";
        String CompanyXML = "<company><stock-exchange><code>NMS</code><name>NASDAQ</name></stock-exchange></company>";

        SerializableEnum<StockExchange> Stock = SerializableEnum<StockExchange>.FromXml(StockXML);
        Company Cmp = Company.FromXml(CompanyXML);

Stock will be populated with the data, but Cmp will not have the Stock data populated (looks like ReadXml never gets called)…

I’ve tried adding additional types to the XmlSerializer (like , new Type[] {typeof(SerializableEnum)}), but that doesn’t help.

What am I missing here? Thanks.

I think it might be something like that RootElementAttribute that I had to add in the FromXml in the SerializableEnum class. The IXmlSerializable ignored the XmlRoot attribute that the enum had, so I added that code to add it when deserializing. Is there a different way to make this all work togeather?

  • 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-06-07T20:01:35+00:00Added an answer on June 7, 2026 at 8:01 pm

    I presume that Company class does NOT implement IXmlSerializable.

    Default Xml serialization ignores all non-public and readonly members, so it ignores protected StockExchangeForXML.

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

Sidebar

Related Questions

i want to have some class like this: [XmlRoot(ElementName = typeof(T).Name + List)] public
[Serializable] public class XX { [XmlAttribute(name)] public string name{get;set;} } [Serializable] [XmlRoot(tree)] public class
I have model: [XmlRoot(ElementName = event, IsNullable=true)] public class Event { public int id
Model for xmlconverter: [XmlRoot(ElementName = location, IsNullable = true)] public class location { public
Consider the following C# code: [XmlRoot] public class A { [XmlArray] public List<B> ArrayOfBItems
I have the following classes [XmlRoot] public class AList { public List<B> ListOfBs {get;
Assume I have a C# class like this: [XmlRoot(floors)] public class FloorCollection { [XmlElement(floor)]
I have a class Image implementing ISerializable : [Serializable] [XmlRoot(ElementName = IMAGE)] [TypeConverter(typeof(ImageTypeConverter))] public
[XmlRoot(ConfigurationRoot)] public class XmlDBConfiguration { [XmlArray(Customers)] [XmlArrayItem(Customer, typeof(Customer))] public ArrayList _customers; private Dictionary<string, Customer>
I have a class written in the following manner: [XmlRoot] public class MyXMLElement {

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.