1
XMLスキーマのすべての要素と属性を示すVB 2008プロジェクトでツリービューを作成しようとしています。VB 2008のXSD要素と属性でtreeviewを埋め込む
XMLスキーマのMSDNドキュメントは、スキーマをXMLSchemaSetに読み込んでコンパイルすると、すべての要素と属性にその値でアクセスする必要がありますが、これは実際には機能していないようです。
のようなforループを使用して:私は単純型の要素名を取得する(と同様のネストされたループと属性名)しelem.Name
を使用することができますが、これは複雑なために動作しません
For Each elem As XmlSchemaElement In compiledSchema.Elements.Values
タイプ。
複雑なタイプの値を取得しようとするたびに、私はレンガの壁に当たった。
例として、以下のスキーマは「書店」要素のみを返します。
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.contoso.com/books" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="bookstore">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="book">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string" />
<xs:element name="author">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="name" type="xs:string" />
<xs:element minOccurs="0" name="first-name" type="xs:string" />
<xs:element minOccurs="0" name="last-name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="price" type="xs:decimal" />
</xs:sequence>
<xs:attribute name="genre" type="xs:string" use="required" />
<xs:attribute name="publicationdate" type="xs:unsignedShort" use="required" />
<xs:attribute name="ISBN" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
それが表示されるようにTreeViewコントロールを移入するのいずれかの方法があります:
bookstore
book
genre
publication date
isbn
title
author
first-name
last-name
price
これは、XMLスキーマでは動作しません。要素名の文字列だけを返す方法はありません。 – melkisadek