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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:52:39+00:00 2026-05-12T07:52:39+00:00

In my XSD, I have something similar to this: <?xml version=1.0 encoding=utf-8 ?> <schema

  • 0

In my XSD, I have something similar to this:

<?xml version="1.0" encoding="utf-8" ?>
<schema xmlns:jump="testThingy" elementFormDefault="qualified" targetNamespace="testThingy" xmlns="http://www.w3.org/2001/XMLSchema">
  <element name="command" type="jump:commandType" />
  <complexType name="loginType">
    <sequence>
      <element name="userName" />
    </sequence>
  </complexType>
  <complexType name="commandType">
    <sequence>
      <choice>
        <element name="login" type="jump:loginType" />
        <element name="logout" />
      </choice>
      <!-- There are other elements here but they are IRRELEVANT to the question -->
    </sequence>
  </complexType>
</schema>

So, using an XSD to C# tool (xsd.exe or Xsd2Code), this generates 2 classes (commandType and loginType). But, if I wanted dto submit a logout command, the XML needs to look like this:

<command>
    <logout />
</command>

But, I haven’t got – whatever the equivalent of a – logoutType. In the generated class, if I wanted to use logout, then commandType is expecting an “XmlElement”.

Assuming the XSD to C# tools can’t generate this class for me, how do you write a class that basically comes down to just serializing to and is of type XmlElement so it fits with the commandType?

(note: I have no control over the XSD’s, otherwise I would have changed it to include a new complexType)

  • 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-12T07:52:40+00:00Added an answer on May 12, 2026 at 7:52 am

    Based on the schema that has now been posted, it’s clear why you have an XmlElement for logout. What do you think the type of the logout element is? It’s xs:anyType. It could be anything at all. The only .NET type that matches that is XmlElement, unless you prefer object.

    What did you want instead of XmlElement?

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

Sidebar

Related Questions

I have something like this (sorry for the bad names) <?xml version=1.0 encoding=utf-8 ?>
Lets assume we have this xml: <?xml version=1.0 encoding=UTF-8?> <tns:RegistryResponse status=urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure xmlns:tns=urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0 xmlns:rim=urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0> <tns:RegistryErrorList
I have one xsd file I'd rather not modify (Exceptions.xsd): <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns=http://me.com/Exceptions.xsd targetNamespace=http://me.com/Exceptions.xsd
It seems I can't easily have an XSD declaration for this simple XML <root>
I have some XML and an XML Schema in a local xsd file. The
I have a mvc.SiteMap defined something like this: <mvcSiteMap xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns=http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0 xsi:schemaLocation=http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0 MvcSiteMapSchema.xsd enableLocalization=true
I have an element that looks something like this. <xsd:element name=container> <xsd:complexType> <xsd:choice minOccurs=0
I have some XSD that looks something like this: <element name=a> <complexType> <sequence> <element
Hi I have xsd schema with base64Binary. when this plugin genereted this elemen looks
I have been assigned to create a XSD schema for a proposed XML. 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.