我必须根据用户输入动态创建一个 XML 文件。
这是我想出的,我遇到了两个问题。
- 如果有相同元素的集合(MaxOccurs = 10)(例如,如果用户输入了 4 个帐户,那么我的代码应该如何)
- 如果有选择选项。根据选择的元素,子元素应该改变。
有人请帮助我。
提前致谢
BB
我的代码:
XElement req =
new XElement("order",
new XElement("client",
new XAttribute("id", clientId),
new XElement("quoteback",
new XAttribute ("name",quotebackname)
)
),
new XElement("accounting",
new XElement("account"),
new XElement("special_billing_id")
),
new XElement("products",
new XElement(
**productChoiceType**,
***** HERE THE ELEMENTS WILL CHAGE BASED ON **productChoiceType**
)
)
)
);