Conditional Logic on XElement objects

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
When using XmlWriter I check for data to determine if the writer should write an element or not and do it this way to successively build a tree of XML elements:
string title = ItemTitleTextBox.Text;<br/>
string link = ItemLinkTextBox.Text;
if(!String.IsNullOrEmpty(title))<br/>
writer1.WriteElementString("title", title);<br/>
if(!String.IsNullOrEmpty(link))<br/>
writer1.WriteElementString("link", link);<br/>
...<br/>
...
<br/>
Can somebody give me a snippet or a link to an article to show how to do so when using XElements to build a tree of XML elements? I tried to use conditional logic inside XElement("title", [logic here] ) but that caused an error.

View the full article
 
Back
Top