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

  • Home
  • SEARCH
  • 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 506017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:39:27+00:00 2026-05-13T06:39:27+00:00

Good day. As i know. There is a root element in XML file. But

  • 0

Good day.

As i know. There is a root element in XML file.

But from the XSD file structure, it is not easy to get the root element value.
Is there any method to do it?

(I wouldn’t like to take use of hard code to find XSD root element value in my project.
i want to find the root element of “RootValueHere”

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="RootValueHere">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="DocumentInfo" minOccurs="1" maxOccurs="1" />
        <xsd:element ref="Prerequisite" minOccurs="1" maxOccurs="1" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <!-- Element of DocumentInfo -->
  <xsd:element name="DocumentInfo">
    <xsd:complexType>
      <xsd:attribute name="Name" type="xsd:string" />
      <xsd:attribute name="Description" type="xsd:string" />
      <xsd:attribute name="Creator" type="xsd:string" />
      <xsd:attribute name="CreateTime" type="xsd:string" />
    </xsd:complexType>
  </xsd:element>
  <!-- Element of Prerequisite -->
  <xsd:element name="Prerequisite">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Type" type="Prerequisite.Type.type" minOccurs="1" maxOccurs="1" />
        <xsd:element name="Miscellaneous" type="Prerequisite.Misc.type" minOccurs="0" maxOccurs="1" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

thank you.

  • 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-13T06:39:27+00:00Added an answer on May 13, 2026 at 6:39 am

    Whilst a single document can only contain one root element, as XSD can actually define multiple valid root elements.

    If you only genuinely want a single type to be valid as a root element, then it should be the only type referenced as an <element>.

    In your schema above, for example, the DocumentInfo and Prerequisite nodes are valid root elements too. To restrict your schema to have just a single, valid root node, replace your DocumentInfo and Prerequisite elements with simple complexType definitions:

    <xsd:complexType name="DocumentInfoType">
        ...
    </xsd:complexType>
    <xsd:complexType name="Prerequisite">
        ....
    </xsd:complexType>
    

    UPDATE: To access the name of an element, you just need to look at the Name property on the XmlElement:

    XmlDocument doc = new XmlDocument();
    doc.Load("D:\\schema.xsd");                      // Load the document from the root of an ASP.Net website
    
    XmlElement schemaElement = doc.DocumentElement;  // The root element of the schema document is the <schema> element
    string elementName = schemaElement.LocalName;    // This will print "schema"
    foreach (XmlNode ele in schemaElement.ChildNodes)
    {
        if (ele.LocalName == "element")
        {
            // This is a valid root node
            // Note that there will be *more than one* of these if you have multiple elements declare at the base level
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning. I have an XML file which contains lists of warning and errors
I know that there have been plenty of topics describing this topic but I
Good day, We just converted our web application .NET 1.1 to .NET 2.0. We
Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
Good day, In visual studio 2005, when I drop a webcontrol in the designer,
I've spent a good part of the day searching, writing and finally scrapping a
Good afternoon, This should be an easy one. I've done the cookie-cutter default ASP.NET
Good day, I am working on a Stratix III FPGA which contains M9K block
Good day sirs, because it looks like mine isn't going to be that good.
I'm totally new to ajax, but pretty good with PHP. I have a PHP

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.