因此,我将 XML 编组和解组到列表中,我有一些用户帐户,其中包含用户名、当前资金等,但单个用户可以拥有一个或多个共享。 <xsd:complexType name="Accounts"> <xsd:sequence> <xsd:element name="Username" type="xsd:string"/> <xsd:element name="Password" type="xsd:string"/> <xsd:element name="Name" type="xsd:string"/> <xsd:element name="Funds" type="xsd:float"/> <xsd:element name="ownedShares"> <xsd:complexType> <xsd:sequence> <xsd:element name="Symbol" maxOccurs="unbounded" type="xsd:string" /> <xsd:element name="Amount" type="xsd:int" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType>我的问题是我不知道如何添加到他们拥有的共享中,我可以添加新用户并更新现有用户,但是更新拥有共享的函数参数是Accounts.OwnedShares value.他们是格式化 XML 的更好方法,因此我可以将新字符串/浮点数插入、添加和更新到帐户 XML 中吗?如果它有帮助,我希望我的 XML 看起来有点像这样 - <Username>Test</Username> <Password>Test</Password> <Name>Test</Name> <Funds>111</Funds> <Shares> <Company>Test</Company> <Amount>111</Amount> </Shares> <Shares> <Company>test2</Company> <Amount>10</Amount> </Shares></Account>
1 回答

慕码人8056858
TA贡献1803条经验 获得超6个赞
将以下内容添加到您的AccountXSD 架构中以Shares正确添加:
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Shares">
<xs:complexType>
<xs:sequence>
<xs:element name="Company" type="xs:string"/>
<xs:element name="Amount" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
有关 XSD 序列的详细信息和示例。
添加回答
举报
0/150
提交
取消