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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:10:09+00:00 2026-05-25T14:10:09+00:00

I have this code: [Serializable] [XmlRoot(ISO_CCY_CODES)] public class IsoCurrencyCodes { public IsoCurrencyCodes() { IsoCodes

  • 0

I have this code:

[Serializable]
    [XmlRoot("ISO_CCY_CODES")]
    public class IsoCurrencyCodes
    {
        public IsoCurrencyCodes()
        {
            IsoCodes = new List<IsoCurrencyCode>();
        }

        public IsoCurrencyCodes(List<IsoCurrencyCode> isoCodes)
        {
            IsoCodes = isoCodes;
        }


        [XmlArrayItem("ISO_CURRENCY")]
        public List<IsoCurrencyCode> IsoCodes { get; set; }

        public static IEnumerable<IsoCurrencyCode> Get()
        {
            var doc = XDocument.Parse(XmlStringIsoCodes.XmlSource.Replace("\r\n", ""));
            var res = doc.Deserialize<IsoCurrencyCodes>();
            return res.IsoCodes;
        }
    }

    [Serializable]
    [XmlRoot("ISO_CURRENCY")]
    public class IsoCurrencyCode
    {
        public IsoCurrencyCode()
        {
        }

        [XmlElement(ElementName = "ENTITY")]
        public string Entity { get; set; }

        [XmlElement(ElementName = "CURRENCY")]
        public string Currency { get; set; }

        [XmlElement(ElementName = "ALPHABETIC_CODE")]
        public string Alpha_Code3 { get; set; }

        [XmlElement(ElementName = "NUMERIC_CODE")]
        public int NumCode { get; set; }

        [XmlElement(ElementName = "MINOR_UNIT")]
        public string MinorUnit { get; set; }
    }

And this code, for deserialization:

public static XDocument Serialize<T>(this T source)
        {
            var ser = new XmlSerializer(source.GetType());
            var sb = new StringBuilder();
            using (var writer = new StringWriter(sb))
            {
                ser.Serialize(writer, source);
            }
            return XDocument.Parse(sb.ToString());
        }

        public static T Deserialize<T>(this XDocument xmlDocument)
        {
            var xmlSerializer = new XmlSerializer(typeof (T));
            using (var reader = xmlDocument.CreateReader())
                return (T) xmlSerializer.Deserialize(reader);
        }

This is the XML source

But deserialization doesn’t work. Please help.
Thanks!

  • 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-25T14:10:09+00:00Added an answer on May 25, 2026 at 2:10 pm

    I believe you only want to use XMLArray if you have a collection element for all of the items to sit underneath. For example here it could be ISO_CURRENCIES. I’m assuming you can’t change the source in this case, so just use this instead:

    [XmlElement("ISO_CURRENCY")]
    public List<IsoCurrencyCode> IsoCodes { get; set; }
    

    You should find that works.

    Additionally, if you find you have further problems in getting the deserialization classes right, you can have them autogenerated for you from the XML and then you can take a look at the code that is created:

    xsd source.xml
    xsd source.xsd /c
    

    This will create source.cs which you can then use in your project or adapt for your own uses.

    As a further note, you’ll find you can’t use int for Minor_Unit as it’s nullable (look at ANTARCTICA). You can’t deserialize straight to an int?, so you’ll either have to make it a string or go via another property, look at this question for more information.

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

Sidebar

Related Questions

I have this code @Entity @Table(name = picture) public class Picture implements Serializable {
I have a code like this: [Serializable] public class A { public int X
please help. I have this code, it's my class to serialize\deserialize application settings. [XmlRoot(EvaStartupData)]
I have this class: <Serializable()> _ Public Class Bonder ''' <summary> ''' General information
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
I have this code :- using (System.Security.Cryptography.SHA256 sha2 = new System.Security.Cryptography.SHA256Managed()) { .. }
Consider the following code: [Serializable] public class Human { public string Name { get;
I have the following class: [Serializable] [XmlRoot ( ElementName = TextData, IsNullable = false)]
hey, I have this code that should save a java.util.Vector of custom serializable classes:
I have a JSF 2.0 bean: @ManagedBean @SessionScoped public class LoginBean implements Serializable {

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.