It seems I am having a bit of trouble with Linq to XML, I have looked for tutorials, but nothing really tells me about from, select, statements. I would like to know how to do a foreach/if statements with linq, if you have a tutorial please let me know. My problem right now is I only want a certain part put into my XML if the textbox has something in it.
The code obviously does not work as you cannot put if statements withing my XDocument. Any help/explanation would be very great
if(txtPr3_Chain.Text != "")
{
new XElement("Property_Info",
new XAttribute("Chain", txtPr3_Chain.Text),
new XElement("City" ,txtPr3_City.Text ),
new XElement("AdRating" ,AdRating3.CurrentRating.ToString()),
new XElement("YourRating" ,YourRating3.CurrentRating.ToString() ),
new XElement("Comment" ,txtPr3_Comments.Text)),
}