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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:38:31+00:00 2026-06-01T02:38:31+00:00

I got the below XML (It is just a part of a big XML

  • 0

I got the below XML (It is just a part of a big XML where I have my problem) that I am trying to make a Serializable class to read the same.

<BANKTRANLIST>
  <DTSTART>20051001</DTSTART>
  <DTEND>20051028</DTEND>
  <STMTTRN> <!-- This element can repeat any number of times -->
    <TRNTYPE>CHECK</TRNTYPE>
    <DTPOSTED>20051004</DTPOSTED>
    <TRNAMT>-200.00</TRNAMT>
  </STMTTRN>
  <STMTTRN>
    <TRNTYPE>ATM</TRNTYPE>
    <DTPOSTED>20051020</DTPOSTED>
    <TRNAMT>-300.00</TRNAMT>
  </STMTTRN>
</BANKTRANLIST>

My C# Implementation

[Serializable]
[XmlRoot("BANKTRANLIST", Namespace = "http://bank.net", IsNullable = false)]
public class BankTransactionList
{
    public BankTransactionList()
    {
        this.StatementTransactions = new List<StatementTransaction>();
    }

    [XmlElement("DTSTART")]
    public string StartDate { get; set; }

    [XmlElement("DTEND")]
    public string EndDate { get; set; }

    [XmlArray("STMTTRN")]
    [XmlArrayItem("STMTTRN")]
    public List<StatementTransaction> StatementTransactions { get; set; }
}


[Serializable]
[XmlRoot("STMTTRN", Namespace = "http://bank.net", IsNullable = false)]
public class StatementTransaction
{
    // TransactionType : ENUM
    [XmlElement("TRNTYPE")]
    public TransactionType TransactionType { get; set; }

    [XmlElement("DTPOSTED")]
    public string DatePosted { get; set; }

    [XmlElement("TRNAMT")]
    public double TransactionAmount { get; set; }
}

My problem is element wrapped again in element which results to get the below output

...
    <STMTTRN> <!-- This does not match my Original XML -->
      <STMTTRN>
        <TRNTYPE>CHECK</TRNTYPE>
        <DTPOSTED>20051004</DTPOSTED>
        <TRNAMT>-200.00</TRNAMT>
      </STMTTRN>
      <STMTTRN>
        <TRNTYPE>ATM</TRNTYPE>
        <DTPOSTED>20051020</DTPOSTED>
        <TRNAMT>-300.00</TRNAMT>
      </STMTTRN>
    </STMTTRN>

Note: Removing [XmlArray(“STMTTRN”)] tag from List property will not resolve this, instead it will be

If any one can correct me or give me a better solution would be great !!

  • 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-01T02:38:32+00:00Added an answer on June 1, 2026 at 2:38 am

    Should be [XmlElement] if you want an element per item without a wrapper element:

    [XmlElement("STMTTRN")]
    public List<StatementTransaction> StatementTransactions { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far i have got the code below which works lovely when trying an
I've got a following problem: I have configured a ant plugin within my pom.xml
I have got below xml in my string and I am using c# 2.0
I am using XSLT and XML. I have got below XML. <documentCountryInformation> <countryCode>US</countryCode> <countryName>United
I have got the XML below, which is stored in string type variable, and
I have a problem trying to get my head around using UTF8 with Poco::XML::XMLWriter
I've got the code below, and I'm trying to set the from field to
I've got a query below. I want to add a condition that if the
This one is weird. I have a list view that is a part of
I have got below code in c#. SqlConnection conn = new SqlConnection(Data Source=MANOJ-PC\\SQLEXPRESS;Initial Catalog=master;Integrated

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.