如何在XML中使用if语句

时间:2014-06-04 11:55:57

标签: xml

我有以下代码:

If dr("dlat").ToString <> "0.000000" Then
                        XmlWriter.WriteStartElement("mapped")
                        XmlWriter.WriteString("Yes")
                        XmlWriter.WriteEndElement()
                    Else
                        XmlWriter.WriteStartElement("mapped")
                        XmlWriter.WriteString("No")
                        XmlWriter.WriteEndElement()
                    End If

我想知道如何使用“是”或“否”部分。 原因是IF mapped = yes然后在xml中添加地址,如果没有则不写地址。

   XmlWriter.WriteStartElement("address")
    XmlWriter.WriteCData(dr("sStreetNumber") & " " & dr("sStreetName"))
    XmlWriter.WriteEndElement()

1 个答案:

答案 0 :(得分:0)

If dr("dlat").ToString <> "0.000000" Then
                        XmlWriter.WriteStartElement("mapped")
                        XmlWriter.WriteString("Yes")
                        XmlWriter.WriteStartElement("address")
                        XmlWriter.WriteCData(dr("sStreetNumber") & " " & dr("sStreetName"))
                        XmlWriter.WriteEndElement()
                    Else
                        XmlWriter.WriteStartElement("mapped")
                        XmlWriter.WriteString("No")
                        XmlWriter.WriteEndElement()
                    End If

这应该可以正常工作吗?