I have some code that create xml file on the fly. Sometimes the node has a value and sometimes not. I need to get open and closing tags <hour>12:00</hour>
or <hour></hour>
even there is no value but I can't find a solution. where the value is empty I am getting <hour />
XmlTextWriter writer = new XmlTextWriter(path + "/" + CustomerId + "/Data/" + CustomerId + ".xml", System.Text.Encoding.UTF8);
writer.WriteStartDocument(true);
writer.Formatting = Formatting.Indented;
writer.Indentation = 2;
writer.WriteStartElement("data");
if (paravalue == null || paravalue == "")
{
writer.WriteStartElement(para);
writer.WriteString("");
writer.WriteEndElement();
}
else
{
writer.WriteStartElement(para);
writer.WriteString(paravalue);
writer.WriteEndElement();
}