目錄
XSD File Generate Class File Simply. 1
Why use XSD file to create C# classes?... 2
How to convert XML file to XSD file?. 2
How to create C# file by XSD file?. 4
What is xsd command params?. 8
Reference. 11
當(dāng)應(yīng)用場景是這樣的:
1. 需要定義大量的自定義格式的XML協(xié)議,供通訊雙方使用,本文基于內(nèi)部接口測試工具的測試協(xié)議格式。
2. 減少中間依賴關(guān)系,類依賴于XML協(xié)議的格式,而非用CS文件序列化XML文件。
準(zhǔn)備一個支持W3C標(biāo)準(zhǔn)的XML文件(必須有文件頭<?xml version="1.0" encoding="utf-8"?>)

<?xml version="1.0" encoding="utf-8" ?><PRotobuftest> <head> <version>1.0.0</version> <description>Bocode protobuf test protocol</description> </head> <transaction> <name>Transaction 01</name> <items> <item> <name>Functional Test 01</name> <description>Test protobuf demo</description> <testinput> <code>4002</code> </testinput> <testparams> <usepretest>false</usepretest> <keystring> <key>10005</key> <value>100</value> <pindex>0</pindex> </keystring> <keybytes> <key>10007</key> <value>12jkjk123jk12312k312k3k1221k3jk21123213k3k13k1</value> <pindex>0</pindex> </keybytes> <keylist> <keystring> <key>30002</key> <value>0</value> <pindex>0</pindex> </keystring> <keystring> <key>30002</key> <value>10</value> <pindex>0</pindex> </keystring> <keystring> <key>30002</key> <value>10</value> <pindex>0</pindex> </keystring> </keylist> </testparams> <testoutput> <resultcode>0</resultcode> </testoutput> </item> <item> <name>Functional Test 02</name> <description>Test protobuf demo</description> <testinput> <code >4002</code> </testinput> <testparams> <keystring> <key>10005</key> <value>100</value> </keystring> <keybytes> <key>10007</key> <value>12jkjk123jk12312k312k3k1221k3jk21123213k3k13k1</value> </keybytes> <keylist> <keystring> <key>30002</key> <value>0</value> </keystring> <keystring> <key>30002</key> <value>10</value> </keystring> <keystring> <key>30002</key> <value>10</value> </keystring> </keylist> </testparams> <testoutput> <resultcode>0</resultcode> </testoutput> </item> </items> </transaction></protobuftest>View Code
以文件方式保存在XXX路徑下,并啟動VS2012 ARM Cross Tools Command Prompt

之后在XXX目錄下即生成ProtobufTest_Demo.xsd文件


首先準(zhǔn)備一個xsd文件,保存在XXX路徑,命名為ProtobufTest_Demo.xsd

<?xml version="1.0" encoding="utf-8"?><xs:schema id="protobuftest" xmlns="" xmlns:xs="http://www.w3.
新聞熱點
疑難解答