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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:12:02+00:00 2026-06-18T04:12:02+00:00

I have to deserialize some xml via a webrequest. My deserializer does not deserizlie

  • 0

I have to deserialize some xml via a webrequest. My deserializer does not deserizlie the meat of the message – but it does not put out an error. It all works if I take out the namespace references on line 2

xml below (edited to hide secret business stuff)

<?xml version="1.0" encoding="UTF-8"?>
<ns2:thingees xmlns:ns2="http://someurl.com">
   <thing thing-code="KE">
     <thingelement description="primary" thing-address="address24000" sequence="1"/>
     <thingelement description="backup" thing-address="address5000" sequence="2"/>
   </thing>
   <thing thing-code="PI">
     <thingelement description="primary" thing-address="address26000" sequence="1"/>
     <thingelement description="backup" thing-address="address27000" sequence="2"/>
   </thing>
</ns2:thingees>

my classes are as below ( renaming things to hide secret business stuff)

[Serializable]
[XmlRoot("thingees", Namespace = "http://someurl.com")]
public class thingeeInfo
{
    [XmlElementAttribute("thing")]
    public oneThing[] Items  {get; set;}
}


public partial class oneThing
{
    [System.Xml.Serialization.XmlElementAttribute("thing-element")]
    public  ThingElement[] thingelement {get; set;}

    [System.Xml.Serialization.XmlAttributeAttribute("thing-code")]
    public string thingcode  {get; set;}

}

public partial class ThingElement
{


    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string description {get; set; }

    [System.Xml.Serialization.XmlAttributeAttribute("thing-address")]
    public string thingaddress  {get; set; }

    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string sequence {get; set; }
}

It all deserializes nicely if I
– take out the namespace references in the root of the xml.
– take out the Namespace reference in the XMlRoot

It deserializes WITHOUT AN ERROR but does not fill the Items – that is, ‘Items’ is null. No ‘things’ are populated

am I supposed to reference the ns2 in the xml? If so, how?

  • 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-18T04:12:03+00:00Added an answer on June 18, 2026 at 4:12 am

    OK, got my answer with more googling.

    It looks like you have to add [XmlType(AnonymousType = true)] to the root
    and [XmlElement(Form = XmlSchemaForm.Unqualified)] to each attribute and/or element

    //  [Serializable]                
    [Xmltype(AnonymousType = true)]     
    [XmlRoot("thingees", Namespace = "http://someurl.com")]
    public class thingeeInfo
    {
        [XmlElementAttribute("thing", Form = XmlSchemaForm.Unqualified))]    
        public oneThing[] Items  {get; set;}
    }
    
    public partial class oneThing
    {
        [XmlElementAttribute("thing-element", Form =XmlSchemaForm.Unqualified))] 
        public  ThingElement[] thingelement {get; set;}
    
        [XmlAttributeAttribute("thing-code", Form = XmlSchemaForm.Unqualified))]   
        public string thingcode  {get; set;}
    
    }
    
    public partial class ThingElement
    {
        [XmlAttributeAttribute(Form = XmlSchemaForm.Unqualified))]                       
        public string description {get; set; }   
    
        [XmlAttributeAttribute("thing-address", Form = XmlSchemaForm.Unqualified))]     
        public string thingaddress  {get; set; }
    
        [XmlAttributeAttribute(Form = XmlSchemaForm.Unqualified))]                        
        public string sequence {get; set; }                   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do not think this is a duplicate. I have done some reading but
I am trying to deserialize some xml into an IList, but I am having
I have some Xml that I need to deserialize into an object. The Xml
I have some XML that I am trying to deserialize. The Kronos_WCF object deserializes
I have some XML that I am trying to deserialize the xml below. <?xml
Basically, I have some xml I need to deserialize. At the time I write
I have some xml files and I am trying to deserialize as below in
i deserialize a widget-hierarchy using gson, but have problems deserializing final fields. Example: public
Possible Duplicate: How to Deserialize XML document Suppose that I have a class that
I'm using the BinaryFormatter.Deserialize(Stream, HeaderHandler). I may have missed something obvious here but I

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.