I am wondering, how can I add a new XElement by using a if/else statement?
For example...
XDocument document = XDocument.Load(this.XMLFile);
document.Element("currentjobs").Add(
new XElement("job",
new XElement("date", now.ToShortDateString() + " " + now.ToUniversalTime()),
new XElement("name", job.name)
)
);
Now if I wanted to add a new XElement inside the element "job" in that XML by using if/else statement from a variable I have in C#.
The if else statement would be like...
if(job.status == 2)
{
//add XML...
}
How would I go ahead and do this?
Thanks!
Abhay ShankerPosted Jun 11, 2014, 1:07 AM
http://stackoverflow.com/questions/6399543/if-xelement-exists-else-create-new-one