Assuming you're creating the XML file yourself, then it's just a matter of creating the specified element and adding it as a child to its parent node with no inner value specified.
xmlnRoot.AppendChild(xmlDoc.CreateElement("date"))
That will create an empty date node ("<date />"). xmlnRoot is an XmlNode object and xmlDoc is an XmlDocument object.
To do this in code, you could simply do:
/// [C#]
// create the date node
// I tend to create objects filled with the node names as constants,
// so that I can easily reference them in a fashion similar to how
// I am entering them. Basically, XMLNames.Date would be "date"
xmleChild = xmlDoc.CreateElement(XMLNames.Date);
// if the string is null or empty, then use an empty node
if ( ! string.IsNullOrEmpty(strDate) )
{
// set the text inside to the date
xmleChild.InnerText = HttpUtility.HtmlEncode(strDate);
}
// add the date node
xmlnRoot.AppendChild(xmleChild);
''' [VB.NET]
' create the date node
' I tend to create objects filled with the node names as constants,
' so that I can easily reference them in a fashion similar to how
' I am entering them. Basically, XMLNames.DateNode would be "date"
xmleChild = xmlDoc.CreateElement(XMLNames.DateNode)
' if the string is null or empty, then use an empty node
If Not String.IsNullOrEmpty(strDate) Then
' set the text inside to the date
xmleChild.InnerText = HttpUtility.HtmlEncode(strDate)
End If
' add the date node
xmlnRoot.AppendChild(xmleChild)
Using the above code would allow you to check to see if the string is both null or empty, and leave the node blank, but still add it regardless. I'm not sure if you meant within Visual Studio or within your app with regards to the second question.