Private Sub generateXML()
'On Error Resume Next
Dim j As Integer = 0
Dim writerXML As XmlTextWriter
'Dim dtRow As DataRow
If IO.File.Exists(".\XMLFileBreakBill.xml") Then
ds = New DataSet
ds.ReadXml(".\XMLFileBreakBill.xml")
If ds.Tables.Count = 0 Then
writerXML = New XmlTextWriter(".\XMLFileBreakBill.xml", System.Text.Encoding.UTF8)
writerXML.WriteStartDocument(True)
writerXML.Formatting = Formatting.Indented
writerXML.Indentation = 4
writerXML.WriteStartElement("breakBill")
writerXML.WriteStartElement("listFollowBill")
writerXML.WriteStartElement("Id")
writerXML.WriteString("1")
writerXML.WriteEndElement()
For j = 0 To dgviewSell.Rows.Count - 1
writerXML.WriteStartElement("List")
writerXML.WriteStartElement("product_name")
writerXML.WriteString(dgviewSell.Rows.Item(j).Cells(0).Value.ToString)
writerXML.WriteEndElement()
writerXML.WriteStartElement("sell_price")
writerXML.WriteString(dgviewSell.Rows.Item(j).Cells(1).Value.ToString)
writerXML.WriteEndElement()
writerXML.WriteStartElement("quantity")
writerXML.WriteString(dgviewSell.Rows.Item(j).Cells(2).Value.ToString)
writerXML.WriteEndElement()
writerXML.WriteStartElement("pay")
writerXML.WriteString(dgviewSell.Rows.Item(j).Cells(3).Value.ToString)
writerXML.WriteEndElement()
writerXML.WriteStartElement("sum_price")
writerXML.WriteString(dgviewSell.Rows.Item(j).Cells(4).Value.ToString)
writerXML.WriteEndElement()
writerXML.WriteEndElement()
Next
writerXML.WriteEndElement()
writerXML.WriteEndElement()
writerXML.WriteEndDocument()
writerXML.Close()
Else
' For j = 0 To dgviewSell.Rows.Count - 1
' ds.Tables(0).Rows.Add(ds.Tables(0).NewRow())
' ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1)("product_name") = dgviewSell.Rows.Item(j).Cells(0).Value.ToString
' ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1)("sell_price") = dgviewSell.Rows.Item(j).Cells(1).Value.ToString
' ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1)("quantity") = dgviewSell.Rows.Item(j).Cells(2).Value.ToString
' ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1)("pay") = dgviewSell.Rows.Item(j).Cells(3).Value.ToString
' ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1)("sum_price") = dgviewSell.Rows.Item(j).Cells(4).Value.ToString
' Next
' ds.AcceptChanges()
' ds.WriteXml(".\XMLFileBreakBill.xml")
End If
Else
Console.WriteLine(" Error : sub generate xml is not file xml")
Exit Sub
End If
End Sub