0

I have an app that writes to XML. If a text box is filled, then I write that value to the XML doc.

writer.WriteStartElement("VEHICLE_LICENSE_NUMBER") '10-28
            writer.WriteString(frmCitation.txtPlate.Text.ToString)
            writer.WriteEndElement()

If TEST123 is the value in the text box, this is the result.

<VEHICLE_LICENSE_NUMBER>TEST123</VEHICLE_LICENSE_NUMBER>

Question is, if that value in the textbox is empty, and not filled in, how do I not even have that line appear in the XML? I'd like it to disappear unless there's a value.

Does anyone have any ideas?

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by mrbungle
2

See if this helps.

With frmCitation.txtPlate
            If Not .Text = "" Then '// check if TextBox has text.
                writer.WriteStartElement("VEHICLE_LICENSE_NUMBER") '10-28
                writer.WriteString(.Text.ToString)
                writer.WriteEndElement()
            End If
        End With
Votes + Comments
Thanks codeorder
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.