How to generate empty node using XElement

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
this way i am generating xml file by XElement

xmlDoc = XDocument.Load(strpath);

XElement liconfig = new XElement("TickerSectionLI",
new XElement("Ticker", _lstTickerSectionLI.FirstOrDefault().Ticker),
new XElement("Section", _lstTickerSectionLI.FirstOrDefault().Section),
new XElement("LI", _lstTickerSectionLI.FirstOrDefault().LI),
new XElement("StandrdFormula", _lstTickerSectionLI.FirstOrDefault().StandrdFormula),
new XElement("StandrdFormulaActual", _lstTickerSectionLI.FirstOrDefault().StandrdFormulaActual),
new XElement("AllowedDecimalPlace", _lstTickerSectionLI.FirstOrDefault().AllowedDecimalPlace),
new XElement("Strikeout", _lstTickerSectionLI.FirstOrDefault().Strikeout));

xmlDoc.Descendants("TickerSectionLI").LastOrDefault().AddAfterSelf(liconfig);
xmlDoc.Save(strpath);


i am looking for a way when _lstTickerSectionLI.FirstOrDefault().Section will be empty then empty Section node will be created in xml file. now Section node has opening & closing tag when _lstTickerSectionLI.FirstOrDefault().Section is empty.

how to generate <Section/> empty section when when _lstTickerSectionLI.FirstOrDefault().Section is empty

please guide me. thanks

Continue reading...
 
Back
Top