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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:42:49+00:00 2026-05-14T00:42:49+00:00

I use C# code more-or-less like this to serialize an object to XML: XmlSerializer

  • 0

I use C# code more-or-less like this to serialize an object to XML:

XmlSerializer xs1 = new XmlSerializer(typeof(YourClassName)); 
StreamWriter sw1 = new StreamWriter(@"c:\DeserializeYourObject.xml"); 
xs1.Serialize(sw1, objYourObjectFromYourClassName); 
sw1.Close(); 

I want it to serialize like this:

<ns0:Header xmlns:ns0="https://mynamespace/">
  <SchemaVersion>1.09</SchemaVersion>
  <DateTime>2009-12-15T00:00:01-08:00</DateTime>

but instead, it is doing this:

 <Header xmlns="https://mynamespace/">
    <SchemaVersion xmlns="">V109</SchemaVersion>
    <DateTime xmlns="">2010-03-08T18:21:09.100125-08:00</DateTime>

The way it is serializing doesn’t work with the XPath I had planned to use, and doesn’t match my BizTalk schema. Originally I built the class using XSD.exe from a BizTalk 2006 schema, then I use it for an argument to a WCF web service.

This might be related to an option called element FormDefault = Qualified or Unqualified. In BizTalk, my I have the schema set to “Unqualfiied” which is what I want.

Is there any way for the serializer to output “unqualified” results?

Thanks,

Neal Walters

Update:

Sample attribute on DateTime:

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public System.DateTime DateTime
{
    get
    {
        return this.dateTimeField;
    }
    set
    {
        this.dateTimeField = value;
    }
}

BizTalk provides for what it calls promoted (or distinguished) fields, which use XPath to pull out values of individual elements. I checked the XPath of BizTalk in a tool called StylusStudio, and Biztalk’x xpath didn’t work with the xmlns=” fields above.

The first thing my WCF web service does is to serialize the object to a string (using UTF16 encoding) and store it in an XML column in a SQL database. It is from there I am seeing the above xml sample with the xmlns=””.

XPath:

/*[local-name()='Header' and namespace-uri()='https://mynamespace/']/*[local-name()='DateTime' and namespace-uri()='']
  • 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-14T00:42:50+00:00Added an answer on May 14, 2026 at 12:42 am

    My question was a bit muddled, so this answer may or may not help someone.
    This is a fairly complex scenario, and half of my issues came from trying to simplify it to make an easy post here.

    I was actually adding a new element programmatically with a C# routine (see “NewElement” below). The C# code did not set its namespace to an empty string, therefore I believe it is inheriting the namespace of the “Header” element.

    I freaked out a little because I was jumping to the conclusion that DateTime should not have the “xmlns=””‘ when in fact it should. Even though DateTime falls under Header, it does not nor should not inherit the Header’s namespace.

    In BizTalk, typically only complex types have their own namespace, and DateTime as well as NewElement are simple types.

     <Header xmlns="https://mynamespace/">
        <SchemaVersion xmlns="">V109</SchemaVersion>
        <DateTime xmlns="">2010-03-08T18:21:09.100125-08:00</DateTime>
        <NewElement>myvalue</NewElement>
    

    So in effect, the two XML’s I posted originally are identical as far as XPath goes. If I insert a new element, I need to make sure it follows the same pattern.

    I had written the C# routine to add the element more than a year ago, and it worked fine then, so I wasn’t suspect that it was causing this problem.

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

Sidebar

Ask A Question

Stats

  • Questions 375k
  • Answers 375k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If I understand your question correctly, the short answer is:… May 14, 2026 at 8:15 pm
  • Editorial Team
    Editorial Team added an answer It could be that the AppPool identity user does not… May 14, 2026 at 8:15 pm
  • Editorial Team
    Editorial Team added an answer Since you already have jQuery referenced on the page, why… May 14, 2026 at 8:15 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.