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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:33:00+00:00 2026-05-22T23:33:00+00:00

My ultimate goal is to traverse an XSD document and display a TreeView (Silverlight

  • 0

My ultimate goal is to traverse an XSD document and display a TreeView (Silverlight 4.0) representation of all the XML elements in order as described by the XSD document.

So, if I had an XSD file that describes a set of elements that would look like

<a>
  <b att1="foo" att2="foo2"/>
    <c />
  <d />
</a>

then I would want to display a TreeView like:

 a
 |_b
 | |_att1
 | |_att2
 | |_c
 |_d

I don’t care if the XSD document allows for multiple occurrences or optional elements and attributes. I want to list elements that occurr multiple times only once, and all required and optional elements/attributes should appear. For example a schema that allows

<a>
  <b att1="foo" att2="this one was optional"/>
    <c />
  <d />
  <d />
</a>

should still return the same TreeView I showed previously.

However, I am having trouble understanding the best way to go about doing this. I started to use an XmlReader to run through the xsd document, but then realized it can become complicated dealing with the references across files… e.g. elements that have “ref” or “type” attributes….or “extension” elements.

So, I created a WCF service so I could use the XmlSchema class and see what was there. I wrote the following code:

XmlTextReader reader = new XmlTextReader("http://myXsdLocation.com/SalesOrder.xsd");
XmlSchema myschema = XmlSchema.Read(reader, ValidationCallback);
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add(myschema);
schemaSet.Compile();

Debugging through that code, the schemaSet count increases to 8 after schemaSet.Compile(), which I assume means that with all the “include” references in the initial xsd file, as well as in the referenced xsd files, there are 8 xsd files altogether for the initial one to make sense.

But from noodling around in the schemaSet objects, I haven’t found a way to elegantly traverse through the entire schema as if it were one giant XSD file.

Does anyone know a way to accomplish what I am trying to do? I just want to be able to pull each element in the order it would appear as one giant XSD file, and any attributes attached to the element and give the data to my TreeView. I’m okay with with the UI stuff, but need to know if it’s better to write my own parser with the XmlReader or to use the XmlSchema and related classes. I’ve found similar questions throughout StackOverflow, but most of it referenced code gen tools or are unrelated to what I am looking for. I want to develop something to take any xsd and produce the tree I mentioned earlier.

  • 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-22T23:33:01+00:00Added an answer on May 22, 2026 at 11:33 pm

    I’m not familiar with the XmlSchema API you refer to.

    Another way to tackle this would be to use the Saxon schema processor to generate an SCM file, which is an XML representation of the schema component model – effectively the compiled schema in “canonical” form, which is an XML representation that is much easier to navigate than the raw XSD files.

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

Sidebar

Related Questions

Here is my ultimate goal... to take this xml file.. <?xml version=1.0?> <Songs> <Song>
My ultimate goal is to build a web crawler capable of downloading all of
Here's my ultimate goal in all of this. I have a viewcontroller with a
I'm working with XML and Python for the first time. The ultimate goal is
My ultimate goal is to have a menu that adds a class to the
My ultimate goal is to load controls as plugins, for use as DocumentContent in
My ultimate goal is to allow users to select a file from a dialog
I am trying to get my head around a LINQ issue. The ultimate goal
I'm working on a project where there is data visualization. My ultimate goal is
This is not a programming question per se, although the ultimate goal is to

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.