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