3
我想使用xsd.exe工具生成的類生成XML文檔。從多個類生成XML
所需的結構是這樣的:
<sh:StandardBusinessDocument xmlns:eanucc="urn:ean.ucc:2" xmlns:order="urn:ean.ucc:order:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader ../Schemas/sbdh/StandardBusinessDocumentHeader.xsd urn:ean.ucc:2 ../Schemas/OrderProxy.xsd" xmlns:sh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader">
<sh:StandardBusinessDocumentHeader>
<sh:HeaderVersion>2.2</sh:HeaderVersion>
</sh:StandardBusinessDocumentHeader>
<eanucc:message>
<entityIdentification>
<uniqueCreatorIdentification>2222</uniqueCreatorIdentification>
</entityIdentification>
</eanucc:message>
</sh:StandardBusinessDocument>
但我只能夠做到這一點:
<sh:StandardBusinessDocument xmlns:eanucc="urn:ean.ucc:2" xmlns:order="urn:ean.ucc:order:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader ../Schemas/sbdh/StandardBusinessDocumentHeader.xsd urn:ean.ucc:2 ../Schemas/OrderProxy.xsd" xmlns:sh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader">
<sh:StandardBusinessDocumentHeader>
<sh:HeaderVersion>2.2</sh:HeaderVersion>
</sh:StandardBusinessDocumentHeader>
<sh:message>
<entityIdentification>
<uniqueCreatorIdentification>2222</uniqueCreatorIdentification>
</entityIdentification>
</sh:message>
</sh:StandardBusinessDocument>
如何創建根節點的孩子的不同節點的前綴?在我生成的類中,我使用XmlTypeAttribute和XmlRootAttribute添加了名稱空間,但第二個子屬性將忽略它們。我班有屬性如下:
爲什麼第二個孩子(StandardBusinessDocumentMessage)裝修被忽略任何想法?
非常好 - 謝謝。添加XmlElement屬性的確有竅門。 – Andrew 2011-04-01 11:05:35