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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:18:48+00:00 2026-05-11T21:18:48+00:00

Currently, I have an xml file that looks like this… <ArrayOfService> <Service> <Name> Something

  • 0

Currently, I have an xml file that looks like this…


<ArrayOfService>
    <Service>
        <Name>
            Something
        </Name>
        <Id>
            8003
        </Id>
    </Service>
</ArrayOfService>

This is automatically generated from a class that looks like this…


public class Service{
    public string Name;
    public int Id;

    public Service(){
    }
}

To turn the class into XML, I use…


XmlSerializer xs = new XmlSerializer( typeof(Service) );
xs.Serialize( context.Response.OutputStream, FunctionReturnsTypeService() );

Is there any way to also automatically generate an XSD like this?

EDIT:

Also, is there any way to add this schema to the xml as I’m serializing it?

  • 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-11T21:18:48+00:00Added an answer on May 11, 2026 at 9:18 pm

    The xsd.exe tool (%netsdk20%\bin\xsd.exe) infers a type from an XML document.

    (You can also use the /c option to generate classes from an xml doc or schema.)

    If you want to embed a reference to a schema into an XML doc, then see here:
    http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.xml/2006-12/msg00040.html

    Summary:
    decorate a member of your type with the XmlAttribute attribute, specifying “schemaLocation” as the name of the attr, and “http://www.w3.org/2001/XMLSchema-instance” as the namespace for that attribute. As this example in C#

    [System.Xml.Serialization.XmlAttributeAttribute("schemaLocation",
        Namespace = System.Xml.Schema.XmlSchema.InstanceNamespace)]
    private string xsiSchemaLocation = "YourSchema.xsd"; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a file-system that looks a little something like this: C:\stuff\build.xml
I have an xml file that looks like this; <Employee> <EmployeeName>Burt Reynolds</EmployeeName> <EmployeeTitle>Bad Ass</EmployeeTitle>
I have an XML file that looks like this <comments> <text> <![CDATA[ <!--cached-Tue, 02
I have an XML feed that looks like this: <?xml version=1.0 encoding=UTF-8?> <productFeed version=1.0
I have this xml snippet as part of a xml file that will be
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
I currently have an MS Access application that connects to a PostgreSQL database via
I currently have a DetailsView in ASP.NET that gets data from the database based
how can I query an xml file where I have multiple items with the
My build path in Eclipse looks like this: ProjectName -- WEB-INF -- classes --

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.