Got it, this is the solution required...
#region xml Meter
doc.Element("Bill").Element("PremiseList").Descendants("Premise").Where(n => n.Attribute("Key").Value == meter.Key.PremiseProviderId.ToString()).Elements("MeterList").FirstOrDefault().Add
(
new XElement
(
"Meter", new XAttribute("MeterId", customerBillActivateModel.CustomerPremiseMeterProviders.FirstOrDefault(x => x.PremiseMeterProviderId == meter.Key.PremiseMeterProviderId).D3001_MeterId),
new XElement("RSA", meter.Key.RSA),
new XElement("PhysicalMeterSize", meter.Key.D3003_PhysicalMeterSize.ToString()),
new XElement("ChargeableMeterSize", meter.Key.D3002_ChargeableMeterSize.ToString()),
new XElement("PrevReadDate", meter.Key.PrevReadDate.ToShortDateString()),
new XElement("PrevRead", meter.Key.PrevRead),
new XElement("LastReadDate", meter.Key.LastReadDate.ToShortDateString()),
new XElement("LastRead", meter.Key.LastRead),
new XElement("ADC", meter.AverageDailyConsumption)
)
);
#endregion xml
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…