I have the the following xsd :
<xs:schema xmlns="urn:bookroom-schema" targetNamespace="urn:bookstore-schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="book" type="xs:string" />
<xs:complexType name="booktype">
<xs:sequence>
<xs:element name="author" type="xs:string" />
<xs:element name="title" type="xs:string" />
<xs:element name="price" type="xs:decimal" />
</xs:sequence>
</xs:complexType>`
<xs:element name="publisher" type="xs:string" />
</xs:schema>
This is the program.
procedure TForm1.AllElementsinSchema;
var oSchemaCache : XMLSchemaCache60;
oSchema : ISchema;
nsTarget: widestring;
kk : integer;
begin
oSchemaCache := coXMLSchemaCache60.Create;
nsTarget := 'urn:bookstore-schema';
oSchemaCache.add(nsTarget,'c:\book.xsd');
oSchema := oSchemaCache.getSchema(nsTarget);
for kk := 0 to pred(oSchema.elements.length) do
showmessage('elements[' + inttostr(kk) + '] : ' + oschema.elements.item[kk].name);
end;
When I run the program I got :
book
publisher
How would I get this (all elements including sub-elements)?
book
author
title
price
publisher
Please guide me how to do it in Delphi. Thanks in advance.
您还必须为oSchema.types
编写一个循环,因为booktype
显然是一种类型( booktype
是complexType
),而不是and元素。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.