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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:55:38+00:00 2026-05-31T19:55:38+00:00

I posted a different flavour of this problem before with no joy. I’m hoping

  • 0

I posted a different flavour of this problem before with no joy. I’m hoping a refactored question will help.

Essentially, i’m loading an XML string into an XDocument then using XDocument.GetReader() to return a XmlReader. From here I’m using a XmlSerializer to deserialise the following XML:

<?xml version='1.0' encoding='UTF-8'?>
<osgb:FeatureCollection
xmlns:osgb='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb'
xmlns:gml='http://www.opengis.net/gml'
xmlns:xlink='http://www.w3.org/1999/xlink'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb http://www.ordnancesurvey.co.uk/xml/schema/v7/OSDNFFeatures.xsd'
fid='GDS-58116-1'>
  <gml:description>OS</gml:description>
  <gml:boundedBy>
    <gml:null>unknown</gml:null>
  </gml:boundedBy>
  <osgb:queryTime>2009-07-30T02:35:17</osgb:queryTime>
  <osgb:queryExtent>
    <osgb:Rectangle srsName='osgb:BNG'>
      <gml:coordinates>291000.000,92000.000 293000.000,94000.000</gml:coordinates>
    </osgb:Rectangle>
  </osgb:queryExtent>  
</osgb:FeatureCollection>

to this class (generated using XSD)

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.ordnancesurvey.co.uk/xml/namespaces/osgb")]
[System.Xml.Serialization.XmlRootAttribute("FeatureCollection", Namespace = "http://www.ordnancesurvey.co.uk/xml/namespaces/osgb", IsNullable = false)]
public partial class FeatureCollectionType : AbstractFeatureCollectionType
{

    private System.DateTime queryTimeField;

    private GeometryPropertyType queryExtentField;

    private System.DateTime queryChangeSinceDateField;

    private bool queryChangeSinceDateFieldSpecified;

    private FeatureAssociationType[] _featureMemberField;

    private BoundingShapeType boundedBy1Field;

    //  more properties

}

The inner exception shows that: <FeatureCollection xmlns='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb'> was not expected.

I can’t see what the problem it. I don’t need a root node above the collection do I?

  • 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-31T19:55:40+00:00Added an answer on May 31, 2026 at 7:55 pm

    I have tested a simplified version (with all properties removed from FeatureCollectionType), and it didn’t throw at the first element:

    private static string xml = 
    @"<?xml version='1.0' encoding='UTF-8'?>
    <osgb:FeatureCollection
       xmlns:osgb='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb'
       xmlns:gml='http://www.opengis.net/gml'
       xmlns:xlink='http://www.w3.org/1999/xlink'
       xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
       xsi:schemaLocation='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb http://www.ordnancesurvey.co.uk/xml/schema/v7/OSDNFFeatures.xsd'
       fid='GDS-58116-1'>
    </osgb:FeatureCollection>";
    
    public static void RunSnippet()
    {
        using (var sr = new StringReader(xml))
        {
            var xs = new XmlSerializer(typeof(FeatureCollectionType));
            var obj = xs.Deserialize(sr);
            Console.WriteLine("if you are reading this, it didn't throw");
        }
    }
    

    How are you instantiating XmlSerializer?

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

Sidebar

Related Questions

I posted a related but still different question regarding Protobuf-Net before, so here goes:
I've posted some questions on this before, but it's different. So consider a small
A while back I posted a different question regarding column order. While this question
This question is in relation to a question I posted yesterday. The link -http://stackoverflow.com/questions/12636348/how-to-add-a-different-class-to-the-same-class-in-jquery
This question is different from the questions posted here and here even though the
This is a different question than the other one I've posted, I have this
I've posted a similar topic/question, but this time it's a bit different. I'm just
I know a similar question has been posted before but I think this is
This post relates to a previous that i posted but the question is different
This is kindred to but different from the question I posted a half hour

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.