T
Trevor
Hello
I need some help with code.
I have a small project where I am currently querying data and I get
back xml because the technology works on xml.
I save the xml file to disk then I load it into the xmldocument object
and parse the xml finding the values I require which I put into a
listview.
I have been told not to use the list view but to rather use a
datatable then bind the data to a datagrid or to serialize the data
then to bind to a datagrid. I am currently using the following code to
get my data into a listview:
Dim xnlHeader As XmlNodeList
xnlHeader = custqueryxml.SelectNodes("//HeaderDetails/Columns/
Column")
' Iterate through a collection
For Each xnNodeColumn As XmlNode In xnlHeader
ListView1.Columns.Add(xnNodeColumn.InnerText, 150)
Next
Dim xnlRow As XmlNodeList
xnlRow = custqueryxml.SelectNodes("//ArCustomerBal/Row")
For Each xnNodeColumn As XmlNode In xnlRow
Dim lvItem As New
ListViewItem(xnNodeColumn.SelectSingleNode("Customer").InnerText)
lvItem.SubItems.Add(xnNodeColumn.SelectSingleNode("CurrentBalance1").InnerText)
ListView1.Items.Add(lvItem)
What would I need to do change this accordingly to use either the
datatable or to serialize and what is the better option?
The second of my questions is:
I need to know take the values "customer" & "CurrentBalance1" and then
build xml for every instance so obviously I need to use the for each
command but I am not to sure of how to code it below is and example of
what I need to do:
Dim xml_elem As String
Dim item As ListViewItem
' Iterate through a collection
For Each item In ListView1.Items
Dim Document As New System.Text.StringBuilder
With Document
.Append("<Item>")
.Append("<Payment>")
.Append("<Customer>" & ???? & "</Customer>")
.Append("<PaymentValue>" & ???? & "</PaymentValue>")
.Append("</Payment>")
.Append("</Item>")
End With
xml_elem = "<PostArPayment>" & Document.ToString & "</
PostArPayment>"
Now the question marks are where the customer value and the
currentbalance1 should go but I am not sure how to get it there and
also if I use the code above the object xml_elem keeps getting
overwritten so it does not build up the xml.
Please help me if you can
I need some help with code.
I have a small project where I am currently querying data and I get
back xml because the technology works on xml.
I save the xml file to disk then I load it into the xmldocument object
and parse the xml finding the values I require which I put into a
listview.
I have been told not to use the list view but to rather use a
datatable then bind the data to a datagrid or to serialize the data
then to bind to a datagrid. I am currently using the following code to
get my data into a listview:
Dim xnlHeader As XmlNodeList
xnlHeader = custqueryxml.SelectNodes("//HeaderDetails/Columns/
Column")
' Iterate through a collection
For Each xnNodeColumn As XmlNode In xnlHeader
ListView1.Columns.Add(xnNodeColumn.InnerText, 150)
Next
Dim xnlRow As XmlNodeList
xnlRow = custqueryxml.SelectNodes("//ArCustomerBal/Row")
For Each xnNodeColumn As XmlNode In xnlRow
Dim lvItem As New
ListViewItem(xnNodeColumn.SelectSingleNode("Customer").InnerText)
lvItem.SubItems.Add(xnNodeColumn.SelectSingleNode("CurrentBalance1").InnerText)
ListView1.Items.Add(lvItem)
What would I need to do change this accordingly to use either the
datatable or to serialize and what is the better option?
The second of my questions is:
I need to know take the values "customer" & "CurrentBalance1" and then
build xml for every instance so obviously I need to use the for each
command but I am not to sure of how to code it below is and example of
what I need to do:
Dim xml_elem As String
Dim item As ListViewItem
' Iterate through a collection
For Each item In ListView1.Items
Dim Document As New System.Text.StringBuilder
With Document
.Append("<Item>")
.Append("<Payment>")
.Append("<Customer>" & ???? & "</Customer>")
.Append("<PaymentValue>" & ???? & "</PaymentValue>")
.Append("</Payment>")
.Append("</Item>")
End With
xml_elem = "<PostArPayment>" & Document.ToString & "</
PostArPayment>"
Now the question marks are where the customer value and the
currentbalance1 should go but I am not sure how to get it there and
also if I use the code above the object xml_elem keeps getting
overwritten so it does not build up the xml.
Please help me if you can