我尝试在 zillow“SearchResults.xsd”上运行 Visual Studio 的 XSD.EXE 实用程序来生成 c# 或 vb.net 类,但没有运气,正在寻求帮助。我不断收到错误(见下文)。这是我从http://www.zillow.com/howto/api/GetDeepSearchResults.htm下载的原始文件:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema attributeFormDefault="unqualified"
elementFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.zillow.com/static/xsd/SearchResults.xsd"
xmlns:ZillowTypes="http://www.zillow.com/static/xsd/ZillowTypes.xsd">
<xsd:import namespace="http://www.zillow.com/static/xsd/ZillowTypes.xsd"
schemaLocation="/vstatic/4/static/xsd/ZillowTypes.xsd" />
<xsd:element name="searchresults">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="request">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="address" type="xsd:string" />
<xsd:element name="citystatezip" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="message" type="ZillowTypes:Message" />
<xsd:element minOccurs="0" name="response">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="results">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="unbounded" name="result" type="ZillowTypes:SimpleProperty" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
以下是我在 Visual Studio 2010 中尝试 XSD.EXE 时不断遇到的错误:
C:\Users\username\Documents>xsd /classes SearchResults.xsd
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: Type 'http://www.zillow.com/static/xsd/ZillowTypes.xsd:Message' is not declared. Line 25, position 6.
Schema validation warning: Type 'http://www.zillow.com/static/xsd/ZillowTypes.xsd:SimpleProperty' is not declared. Line 33, position 12.
Warning: Schema could not be validated. Class generation may fail or may produce
incorrect results.
Error: Error generating classes for schema 'SearchResults'.
- The datatype 'http://www.zillow.com/static/xsd/ZillowTypes.xsd:Message' is missing.
看起来一切都在 ZillowTypes.xsd 中定义,所以我很难过。