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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:56:29+00:00 2026-06-01T03:56:29+00:00

Model for xmlconverter: [XmlRoot(ElementName = location, IsNullable = true)] public class location { public

  • 0

Model for xmlconverter:

[XmlRoot(ElementName = "location", IsNullable = true)]
public class location
{
    public string city { get; set; }
    public string country { get; set; }
    public string street { get; set; }
    public string postalcode { get; set; }
    [XmlElement(ElementName = "geo:point")]
    public geoLocation geo { get; set; }
}

[XmlRoot(ElementName = "geo:point", Namespace="http://www.w3.org/2003/01/geo/wgs84_pos#")]
public class geoLocation
{
    [XmlElement(ElementName = "geo:lat", Namespace="http://www.w3.org/2003/01/geo/wgs84_pos#")]
    public string lat { get; set; }
    [XmlElement(ElementName = "geo:long", Namespace = "http://www.w3.org/2003/01/geo/wgs84_pos#")]
    public string lon { get; set; }
}

xml:

<location>
 <city>Moscow</city>
 <country>Russian Federation</country>
 <street></street>
 <postalcode>236000</postalcode>
 <geo:point>
 <geo:lat>54.727483</geo:lat>
 <geo:long>20.501132</geo:long>
 </geo:point>
</location>

Location is ok, but geo – not. What should I do?
I tried to erase namespaces and there’s no changes

  • 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-01T03:56:31+00:00Added an answer on June 1, 2026 at 3:56 am

    You’ve got two problems here. One, as mentioned by Peter Aron Zentai is that you need to apply the namespace at the property level. XmlRoot only has an effect if it is placed on the root object (which in your case is location).

    The second problem is that by including the prefix in the element name, you are actually saying you have an element called “geo:point”. What you should be saying is you have an element named “point”, in the namespace “http://www.w3.org/2003/01/geo/wgs84_pos#”, which has the prefix “geo”.

    To correct the first problem – simply move the namespace specifier from XmlRoot, to the property itself. To correct the second, remove the prefix from the element name, and set up the namespaces correctly on the serializer, with a prefix of “geo”:

    [XmlRoot(ElementName = "location", IsNullable = true)]
    public class location
    {
        public string city { get; set; }
        public string country { get; set; }
        public string street { get; set; }
        public string postalcode { get; set; }
        [XmlElement(ElementName = "point", Namespace = "http://www.w3.org/2003/01/geo/wgs84_pos#")]
        public geoLocation geo { get; set; }
    }
    
    public class geoLocation
    {
        [XmlElement(ElementName = "lat", Namespace = "http://www.w3.org/2003/01/geo/wgs84_pos#")]
        public string lat { get; set; }
        [XmlElement(ElementName = "long", Namespace = "http://www.w3.org/2003/01/geo/wgs84_pos#")]
        public string lon { get; set; }
    }
    
    var serializer = new XmlSerializer(typeof (location));
    var namespace = new XmlQualifiedName("geo", "http://www.w3.org/2003/01/geo/wgs84_pos#");
    var namespaces = new XmlSerializerNamespaces(new [] { namespace });
    serializer.Serialize(myOutputStreamOrWriter, location, namespaces);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Model: public class EmailAttachment { public string FileName { get; set; } public string
Example model: public class Thing { [JsonProperty(foo)] public string Foo {get;set;} [JsonProperty(bars)] public Dictionary<string,string>
Model: public sealed class Model { public string Value { get; set; } }
//Model public class SelectModel { public string CategoryId { get; set; } public List<SelectListItem>
Model: public class Model { public ItemType Type { get; set; } public int
/// Model public class MenuModels { public Int32 MenuId { get; set; } public
Model public class PdfPage { public IEnumerable<PdfPhoto> Photos { get; set; } } public
My model is as follows: public class testCreateModel { public string s1 { get;
Model : public IEnumerable<Role> Roles { get; set; } Index : Roles = securityServiceClient.GetAllRoles()
model: class Province(models.Model): user = models.ManyToManyField(User, blank=True) name = models.CharField(max_length=30, unique=True) class City(models.Model): name

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.