我需要根据用户输入动态创建一个XML文件。
以下是我想出来的代码,但我遇到了两个问题:
1. 如果有多个相同的元素(MaxOccurs = 10),例如如果用户输入了4个账户,那么我的代码应该如何处理?
2. 如果有选择选项,则基于所选元素,子元素应更改。
请有经验的人帮助我。
提前感谢!
BB
我的代码:
以下是我想出来的代码,但我遇到了两个问题:
1. 如果有多个相同的元素(MaxOccurs = 10),例如如果用户输入了4个账户,那么我的代码应该如何处理?
2. 如果有选择选项,则基于所选元素,子元素应更改。
请有经验的人帮助我。
提前感谢!
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**
)
)
)
);
...new XElement(p.Name, from t in thingRepository.GetByProductName(p.Name) select new Element(t.Whatever)
- StriplingWarrior