473,698 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(TemplateB 62,TemplateC62 ......)

<?xml version='1.0' encoding='UTF-8'?>
<xsd:schema targetNamespace ="http://tempuri.org/XMLSchema.xsd"
elementFormDefa ult="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:complexTyp e name="RootType" >
<xsd:all>
<xsd:element name="TemplateB 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateC 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateD 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateE 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>

<xsd:element name="TemplateK 86_1" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
</xsd:all>
</xsd:complexType >
</xsd:schema>
Thank you in advance,

--Michael
Nov 12 '05 #1
2 1696
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"),nu ll);
schema.Compile( );
foreach (XmlSchemaEleme nt 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**@discussio ns.microsoft.co m> wrote in message
news:79******** *************** ***********@mic rosoft.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(TemplateB 62,TemplateC62 .......)
<?xml version='1.0' encoding='UTF-8'?>
<xsd:schema targetNamespace ="http://tempuri.org/XMLSchema.xsd"
elementFormDefa ult="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:complexTyp e name="RootType" >
<xsd:all>
<xsd:element name="TemplateB 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateC 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateD 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateE 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>

<xsd:element name="TemplateK 86_1" type="xsd:strin g" 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"),nu ll);
schema.Compile( );
foreach (XmlSchemaEleme nt 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**@discussio ns.microsoft.co m> wrote in message
news:79******** *************** ***********@mic rosoft.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(TemplateB 62,TemplateC62

.......)

<?xml version='1.0' encoding='UTF-8'?>
<xsd:schema targetNamespace ="http://tempuri.org/XMLSchema.xsd"
elementFormDefa ult="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:complexTyp e name="RootType" >
<xsd:all>
<xsd:element name="TemplateB 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateC 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateD 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>
<xsd:element name="TemplateE 62" type="xsd:strin g" minOccurs="0"
nillable="true" form="qualified "/>

<xsd:element name="TemplateK 86_1" type="xsd:strin g" 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
1649
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 element with many attributes. Here I am attaching my XML and XST. Please provide me how I should unmarshal and use this XST.
0
1769
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 example schema <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ...>
4
7240
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 across is documentation for validating XML files against XSD files. Is ther any way to parse the XSD file itself? Any help will be appreciated. Thanks for your time.
2
3953
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 Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\ You selected the file named AAA.XML getXmlAlgorithmDocument(): IOException Not logged in
0
4123
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 have an schema (s1) on an Oracle 9i database with database links pointing to a schema (s2) on another Oracle 9i database.
8
2700
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
3074
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 and an XSD schema, both located on my harddisk, against each other without any problems. I can therefore also parse the schema file and access it the same way than a common xml file. The question now is whether Xerces provides the possibility to...
1
3435
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 standards. first change done in schema section i have something defined like this <xsd:complexType name="CallTermType" abstract="true"/> which is used in later sections as <xsd:complexType name="EndOfPage">
1
3142
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" elementFormDefault="qualified" version="1.0"> <complexType name="PSType"> <element ref="tns:ProfileName" maxOccurs="unbounded"/>
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.