Hi Parth,
Thanks for the quick response. I have made some progress overnight. I was able to generate the output I need using the API Toolbox. The output I get from my server with license details substituted is
<?xml version="1.0" encoding="UTF-8"?>
<admin_response>
<hasp>
<vendorid>12345</vendorid>
<haspid>123456789</haspid>
<typename>HASP HL Net 10</typename>
<local>Local</local>
<localname>Local</localname>
</hasp>
<hasp>
<vendorid>12345</vendorid>
<haspid>123456789</haspid>
<typename>HASP HL Net 10</typename>
<local>Local</local>
<localname>Local</localname>
</hasp>
<hasp>
<vendorid>12345</vendorid>
<haspid>123456789</haspid>
<typename>HASP HL Net 10</typename>
<local>Local</local>
<localname>Local</localname>
</hasp>
<hasp>
<vendorid>12345</vendorid>
<haspid>123456789</haspid>
<typename>HASP HL Net 10</typename>
<local>Local</local>
<localname>Local</localname>
</hasp>
<hasp>
<vendorid>12345</vendorid>
<haspid>123456789</haspid>
<typename>HASP HL Net 10</typename>
<local>Local</local>
<localname>Local</localname>
</hasp>
<hasp>
<vendorid>12345</vendorid>
<haspid>123456789</haspid>
<typename>HASP HL Net 10</typename>
<local>Local</local>
<localname>Local</localname>
</hasp>
<hasp>
<vendorid>12345</vendorid>
<haspid>123456789</haspid>
<typename>HASP HL NetTime 10</typename>
<local>00.00.00.00</local>
<localname>ABC-DEFxxxxxx</localname>
</hasp>
<admin_status>
<code>0</code>
<text>SNTL_ADMIN_STATUS_OK</text>
</admin_status>
</admin_response>
I have generated the XSD file to suit this output via VBA script. The code generates the file below.
Sub Create_XSD()
Dim StrMyXml As String, MyMap As XmlMap
Dim StrMySchema As String
StrMyXml = "<admin_response>"
StrMyXml = StrMyXml & "<hasp>"
StrMyXml = StrMyXml & "<vendorid>999</vendorid>"
StrMyXml = StrMyXml & "<haspid>999</haspid>"
StrMyXml = StrMyXml & "<typename>Text</typename>"
StrMyXml = StrMyXml & "<local>999</local>"
StrMyXml = StrMyXml & "<localname>999</localname>"
StrMyXml = StrMyXml & "</hasp>"
StrMyXml = StrMyXml & "<hasp></hasp>"
StrMyXml = StrMyXml & "<admin_status>"
StrMyXml = StrMyXml & "<code>999</code>"
StrMyXml = StrMyXml & "<text>Text</text>"
StrMyXml = StrMyXml & "<numError>999</numError>"
StrMyXml = StrMyXml & "<error>999</error>"
StrMyXml = StrMyXml & "</admin_status>"
StrMyXml = StrMyXml & "<admin_status></admin_status>"
StrMyXml = StrMyXml & "</admin_response>"
' Turn off async loading.
Application.DisplayAlerts = False
' Add the string to the XmlMaps collection.
Set MyMap = ThisWorkbook.XmlMaps.Add(StrMyXml)
Application.DisplayAlerts = True
' Create an empty file and output the schema.
StrMySchema = ThisWorkbook.XmlMaps(1).Schemas(1).XML
Open "C:\Users\pete\Desktop\HaspSchema1.xsd" For Output As #1
Print #1, StrMySchema
Close #1
End Sub
XSD File:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:element nillable="true" name="admin_response"><xsd:complexType><xsd:sequence minOccurs="0"><xsd:element minOccurs="0" maxOccurs="unbounded" nillable="true" name="hasp" form="unqualified"><xsd:complexType><xsd:sequence minOccurs="0"><xsd:element minOccurs="0" nillable="true" type="xsd:integer" name="vendorid" form="unqualified"></xsd:element><xsd:element minOccurs="0" nillable="true" type="xsd:integer" name="haspid" form="unqualified"></xsd:element><xsd:element minOccurs="0" nillable="true" type="xsd:string" name="typename" form="unqualified"></xsd:element><xsd:element minOccurs="0" nillable="true" type="xsd:integer" name="local" form="unqualified"></xsd:element><xsd:element minOccurs="0" nillable="true" type="xsd:integer" name="localname" form="unqualified"></xsd:element></xsd:sequence></xsd:complexType></xsd:element><xsd:element minOccurs="0" maxOccurs="unbounded" nillable="true" name="admin_status" form="unqualified"><xsd:complexType><xsd:sequence minOccurs="0"><xsd:element minOccurs="0" nillable="true" type="xsd:integer" name="code" form="unqualified"></xsd:element><xsd:element minOccurs="0" nillable="true" type="xsd:string" name="text" form="unqualified"></xsd:element></xsd:sequence></xsd:complexType></xsd:element></xsd:sequence></xsd:complexType></xsd:element></xsd:schema>
Can you see any errors in the XSD code or generated file? Should the Status appear in every line or just the last one?
Apologies for the long post!
Thanks,
Pete.