因此,我将 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>
慕码人8056858
相关分类