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

  • Home
  • SEARCH
  • 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 3315490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:21:23+00:00 2026-05-17T22:21:23+00:00

Having problems deserializing some xml into an object in C#. The error that I

  • 0

Having problems deserializing some xml into an object in C#.

The error that I receive is…

xmlns=''> was not expected.

The XSD that I received to generate my class is as follows…

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="xml.AAAAAAA.com/commerce/apres-vente_technique/assistance" xmlns:pgp="xml.AAAAAAA.com/commerce/apres-vente_technique/assistance" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="ListeAvisRemboursements">
        <xs:annotation>
            <xs:documentation>Liste des avis de remboursements</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence maxOccurs="unbounded">
                <xs:element name="AvisRemboursement" type="pgp:AvisRemboursementType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="AvisRemboursementType">
        <xs:annotation>
            <xs:documentation>Avis de remboursement lié à une DC</xs:documentation>
        </xs:annotation>
        <xs:sequence>

(snipped)

The file that I am attempting to import is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<ListeAvisRemboursements xmlns:ast="xml.AAAAAAA.com/commerce/apres-vente_technique/assistance">
    <ast:AvisRemboursement NumeroDT="3826961" CodeRA="020545G01" NumeroDC="1">
        <ast:DateTraitement>2010-06-22</ast:DateTraitement>
        <ast:MontantDC>25.0</ast:MontantDC>
        <ast:MontantMO>0.0</ast:MontantMO>
        <ast:SommeAD>25.0</ast:SommeAD>
        <ast:MontantPR>0.0</ast:MontantPR>
        <ast:SommePR>0.0</ast:SommePR>
        <ast:FraisGestion>0.0</ast:FraisGestion>
        <ast:NombreHeuresTotalRemboursees>0</ast:NombreHeuresTotalRemboursees>
        <ast:Etat>C</ast:Etat>
        <ast:NoteCredit>319984</ast:NoteCredit>
        <ast:Imputation>030</ast:Imputation>
        <ast:ListInterventionsPR/>
        <ast:ListInterventionsMO/>
    </ast:AvisRemboursement>

(snipped)

I think what is happening is that when .Net attempts to derserialize the xml, it hits the first line which contains the “xmlns:ast” and complaints about it. As I understand it, .Net will try to map attributes to a public property in the target class (and it wont find one called xmlns. Or there is something wrong with how I am handling the name spaces.

My deserialization code looks as follows:

    XmlDocument _Doc = new XmlDocument();
    _Doc.Load(@"C:\inputfile.xml");

    XmlSerializer _XMLSer = new XmlSerializer(typeof(ListeAvisRemboursements));
    ListeAvisRemboursements _X = (ListeAvisRemboursements)_XMLSer.Deserialize(new StringReader(_Doc.OuterXml));

I have also tried various combinations of adding a namespace manager to the XML document..

XmlNamespaceManager _Ns = new XmlNamespaceManager(_Doc.NameTable);
_Ns.AddNamespace("ast", "xml.AAAAAAA.com/commerce/apres-vente_technique/assistance");

I understand there is a way I can use this to tell .Net what namespaces to accept.

Would be greatful for some help iwth this problem.

— Updated at request with class snippet (sorry should have included before) this was created with xsd.exe —

 /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "xml.AAAAAAA.com/commerce/apres-vente_technique/assistance")]
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "xml.AAAAAAA.com/commerce/apres-vente_technique/assistance", IsNullable = false)]
    public partial class ListeAvisRemboursements
    {

        private AvisRemboursementType[] avisRemboursementField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("AvisRemboursement")]
        public AvisRemboursementType[] AvisRemboursement
        {
            get
            {
                return this.avisRemboursementField;
            }
            set
            {
                this.avisRemboursementField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "xml.AAAAAAA.com/commerce/apres-vente_technique/assistance")]
    public partial class AvisRemboursementType
    {

        private System.DateTime dateTraitementField;

        private double montantDCField;

        private double montantMOField;

        private double sommeADField;

        private double montantPRField;
  • 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-17T22:21:24+00:00Added an answer on May 17, 2026 at 10:21 pm

    Without a full xsd / xml, or (alternatively) your C# classes, we can’t reproduce. But working from the xml upwards, this works fine for me; meaning: the error is not (as far as I can see) in the code/data you posted. Can you post a more complete (reproducible) example?

    public class ListeAvisRemboursements
    {
        private readonly List<AvisRemboursement> items = new List<AvisRemboursement>();
        [XmlElement("AvisRemboursement", Namespace = "xml.AAAAAAA.com/commerce/apres-vente_technique/assistance")]
        public List<AvisRemboursement> Items { get { return items; } }
    }
    public class AvisRemboursement
    {
        [XmlAttribute] public string NumeroDT {get;set;}
        [XmlAttribute] public string CodeRA {get;set;}
        [XmlAttribute] public string NumeroDC {get;set;}
        public DateTime DateTraitement { get; set; }
        public decimal MontantDC { get; set; }
        public decimal MontantMO { get; set; }
        public decimal SommeAD { get; set; }
        public decimal MontantPR { get; set; }
        public decimal SommePR { get; set; }
        public decimal FraisGestion { get; set; }
        public int NombreHeuresTotalRemboursees { get; set; }
        public string Etat { get; set; }
        public string NoteCredit { get; set; }
        public string Imputation { get; set; }
    }
    static void Main()
    {
        var ser = new XmlSerializer(typeof(ListeAvisRemboursements));
        var wrapper = (ListeAvisRemboursements)ser.Deserialize(new StringReader(xml));
        // inspect wrapper.Items etc
    }
    

    also works fine with:

    var ser = new XmlSerializer(typeof(ListeAvisRemboursements));
    using (var reader = XmlReader.Create("inputfile.xml"))
    {
        var wrapper = (ListeAvisRemboursements)ser.Deserialize(reader);
    }
    

    and:

    XmlDocument _Doc = new XmlDocument();
    _Doc.Load("inputfile.xml");
    var ser = new XmlSerializer(typeof(ListeAvisRemboursements));
    var wrapper = (ListeAvisRemboursements)ser.Deserialize(new StringReader(_Doc.OuterXml));
    

    and

    XmlDocument _Doc = new XmlDocument();
    _Doc.Load("inputfile.xml");
    var ser = new XmlSerializer(typeof(ListeAvisRemboursements));
    var wrapper = (ListeAvisRemboursements)ser.Deserialize(new XmlNodeReader(_Doc.DocumentElement));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problems manually looping through xml data that is received via an
I'm having problems deserializing some json data, getting InvalidCastExceptions and the like. Can anyone
Hey, I am having a problem deserializing base64 json back into the .net object
I'm having problems using textures that are larger than the OpenGL window or the
Im having problems displaying records to my view when passing viewdata to a user
Im having problems building a query with the linq to sql data query expression
I have recently started having problems with TortoiseCVS, or more specifically with plink, the
I'm having problems deciding on what is the best way is to handle and
I am having problems getting text within a table to appear centered in IE.
I am having problems converting a string in the format yyyy-MM-ddZ using VB.net. For

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.