473,382 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Parsing XML Schema, How To, please

Hi! I have an Excel 2003 Schema I need to parse to extract elements names.
I am puzzled which System.Xml object can help me. Here's the example of my
schema:

I need to get a collection of element names(TemplateB62,TemplateC62 ......)

<?xml version='1.0' encoding='UTF-8'?>
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://tempuri.org/XMLSchema.xsd">
<xsd:annotation>XSD Schema generated with Excel XML Toolbox</xsd:annotation>
<xsd:element name="Root" type="RootType"/>
<xsd:complexType name="RootType">
<xsd:all>
<xsd:element name="TemplateB62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateC62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateD62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateE62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>

<xsd:element name="TemplateK86_1" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
Thank you in advance,

--Michael
Nov 12 '05 #1
2 1674
Load the XSD in a XmlSchema object and call Compile(), you can then access
all global elements via the
Elements collection.[1]

Given an XSD file called schema.xsd the code looks like:
Code:
XmlSchema schema = XmlSchema.Read(new XmlTextReader("schema.xsd"),null);
schema.Compile();
foreach (XmlSchemaElement elemenet in schema.Elements.Values)
{
// Access the Element properties here , like QualifiedName etc.
}
[1]
http://msdn.microsoft.com/library/de...mentstopic.asp
Thanks.
"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Hi! I have an Excel 2003 Schema I need to parse to extract elements names.
I am puzzled which System.Xml object can help me. Here's the example of my schema:

I need to get a collection of element names(TemplateB62,TemplateC62 .......)
<?xml version='1.0' encoding='UTF-8'?>
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/XMLSchema.xsd">
<xsd:annotation>XSD Schema generated with Excel XML Toolbox</xsd:annotation> <xsd:element name="Root" type="RootType"/>
<xsd:complexType name="RootType">
<xsd:all>
<xsd:element name="TemplateB62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateC62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateD62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateE62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>

<xsd:element name="TemplateK86_1" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
Thank you in advance,

--Michael

Nov 12 '05 #2
Thank you very much for taking a look. Your answer brought me closer to the
solution. I tried your approach and only get the Root of the schema file.
I can not seem to be able to reach the elements.

Please let me know if you know what I do wrong.

Numerous thanks in advance,

--Michael
"Zafar Abbas" wrote:
Load the XSD in a XmlSchema object and call Compile(), you can then access
all global elements via the
Elements collection.[1]

Given an XSD file called schema.xsd the code looks like:
Code:
XmlSchema schema = XmlSchema.Read(new XmlTextReader("schema.xsd"),null);
schema.Compile();
foreach (XmlSchemaElement elemenet in schema.Elements.Values)
{
// Access the Element properties here , like QualifiedName etc.
}
[1]
http://msdn.microsoft.com/library/de...mentstopic.asp
Thanks.
"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Hi! I have an Excel 2003 Schema I need to parse to extract elements names.
I am puzzled which System.Xml object can help me. Here's the example of

my
schema:

I need to get a collection of element names(TemplateB62,TemplateC62

.......)

<?xml version='1.0' encoding='UTF-8'?>
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"

xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://tempuri.org/XMLSchema.xsd">
<xsd:annotation>XSD Schema generated with Excel XML

Toolbox</xsd:annotation>
<xsd:element name="Root" type="RootType"/>
<xsd:complexType name="RootType">
<xsd:all>
<xsd:element name="TemplateB62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateC62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateD62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
<xsd:element name="TemplateE62" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>

<xsd:element name="TemplateK86_1" type="xsd:string" minOccurs="0"
nillable="true" form="qualified"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
Thank you in advance,

--Michael


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: my_questions | last post by:
Hi I am new to JAXB. I am trying to unmarshal a XST. I have looked into many examples and they provide to unmarshal if we have a XST with Tags withing Tags. However I have an XST where I have a...
0
by: Ewan B | last post by:
Hi, I'm using Xerces to parse XML files using SAX2, and am wondering if there is any information as to what exceptions are being thrown when certain validation errors occur. Taking a simple...
4
by: Pushya | last post by:
Hello - I am trying to parse a .XSD file to obtain information about element name and type in the file. I have been trying to find some kind of documentation for Schema Parsing. All I come...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
0
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We...
8
by: pradeepsarathy | last post by:
Hi all, Does the SAX parser has eventhandlers for parsing xml schema. Can we parse the xml schema the same way as we parse the xml document using SAX Parser. Thanks in advance. -pradeep
1
by: christian.eickhoff | last post by:
Hi, I have a general question regarding the parsing of XSD files, referenced within the namespace using Apache Xerces 2.7.0 (CDT). My current c++ application can parse and validate an XML file...
1
by: padmagvs | last post by:
I am working on some code which parses wsdl . I have a complex wsdl which is failing to parse . I have to modify this wsdl for parsing . wanted to know the complex wsdl i am using is as per...
1
by: JJadhav | last post by:
I have written the following schema file: <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.abc.com/DDSchema" targetNamespace="http://www.abc.com/DDSchema"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.