我的一个项目遇到了一些麻烦。它是使用 VB.net 的 windows mobile 5 的基本财务经理。一切正常,但是,当一个值保存在 xml 中时,当另一个值被保存时,它将被覆盖。我希望它添加这些值而不是完全覆盖它们。
我的代码:
Private Sub MenuItem3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
Dim writer As New XmlTextWriter("product.xml", Nothing)
writer.WriteStartDocument(True)
writer.Formatting = Formatting.Indented
writer.Indentation = 2
writer.WriteStartElement("Table")
createNode(DateTimePicker.Text, Subject.Text, Category.Text, Amount.Text, PaymentLabel.Text, writer)
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
End Sub
Private Sub createNode(ByVal eDate As String, ByVal eSubject As String, ByVal eCategory As String, ByVal eAmount As String, ByVal ePayment As String, ByVal writer As XmlTextWriter)
writer.WriteStartElement("Expenses")
writer.WriteStartElement("Date")
writer.WriteString(eDate)
writer.WriteEndElement()
writer.WriteStartElement("Subject")
writer.WriteString(eSubject)
writer.WriteEndElement()
writer.WriteStartElement("Category")
writer.WriteString(eCategory)
writer.WriteEndElement()
writer.WriteStartElement("Amount")
writer.WriteString(eAmount)
writer.WriteEndElement()
writer.WriteStartElement("Payment")
writer.WriteString(ePayment)
writer.WriteEndDocument()
End Sub