dastaub
asked on
VB.net XML output
The below visual basic Sub ProcessPatientVolume() successfully creates this XML output:
<Volume>
<FacNo>183</FacNo>
<YearMonth>201312</YearMon th>
<Visits>1</Visits>
<FacNo>183</FacNo>
<YearMonth>201401</YearMon th>
<Visits>1</Visits>
<FacNo>203</FacNo>
<YearMonth>201311</YearMon th>
<Visits>1</Visits>
<FacNo>203</FacNo>
<YearMonth>201401</YearMon th>
<Visits>1</Visits>
</Volume>
I would like the output to include <Item></Item> as shown below:
<Volume>
<Item>
<FacNo>183</FacNo>
<YearMonth>201312</YearMon th>
<Visits>341</Visits>
</Item>
<Item>
<FacNo>183</FacNo>
<YearMonth>201401</YearMon th>
<Visits>431</Visits>
</Item>
</Volume>
How can I add <Item></Item> to the XML output?
Private Sub ProcessPatientVolume()
dim xVolume As New XElement("Volume")
Dim SQL As String = ""
SQL = "SELECT FacNo, SUBSTRING(TimeIn, 1, 6) AS YearMonth, COUNT(VisitID) AS Visits FROM Visit GROUP BY FacNo, SUBSTRING(TimeIn, 1, 6) ORDER BY FacNo, YearMonth"
Try
Using CNN As New SqlConnection(CSCLI)
CNN.Open()
Using CMD As New SqlCommand(SQL, CNN)
Using DR As SqlDataReader = CMD.ExecuteReader
While DR.Read
xVolume.Add(New XElement("FacNo", DR.Item("FacNo").ToString) )
xVolume.Add(New XElement("YearMonth", DR.Item("YearMonth").ToStr ing))
xVolume.Add(New XElement("Visits", DR.Item("Visits").ToString ))
End While
End Using
End Using
End Using
Catch ex As Exception
LOG(ex.ToString)
ex = Nothing
End Try
End Sub
<Volume>
<FacNo>183</FacNo>
<YearMonth>201312</YearMon
<Visits>1</Visits>
<FacNo>183</FacNo>
<YearMonth>201401</YearMon
<Visits>1</Visits>
<FacNo>203</FacNo>
<YearMonth>201311</YearMon
<Visits>1</Visits>
<FacNo>203</FacNo>
<YearMonth>201401</YearMon
<Visits>1</Visits>
</Volume>
I would like the output to include <Item></Item> as shown below:
<Volume>
<Item>
<FacNo>183</FacNo>
<YearMonth>201312</YearMon
<Visits>341</Visits>
</Item>
<Item>
<FacNo>183</FacNo>
<YearMonth>201401</YearMon
<Visits>431</Visits>
</Item>
</Volume>
How can I add <Item></Item> to the XML output?
Private Sub ProcessPatientVolume()
dim xVolume As New XElement("Volume")
Dim SQL As String = ""
SQL = "SELECT FacNo, SUBSTRING(TimeIn, 1, 6) AS YearMonth, COUNT(VisitID) AS Visits FROM Visit GROUP BY FacNo, SUBSTRING(TimeIn, 1, 6) ORDER BY FacNo, YearMonth"
Try
Using CNN As New SqlConnection(CSCLI)
CNN.Open()
Using CMD As New SqlCommand(SQL, CNN)
Using DR As SqlDataReader = CMD.ExecuteReader
While DR.Read
xVolume.Add(New XElement("FacNo", DR.Item("FacNo").ToString)
xVolume.Add(New XElement("YearMonth", DR.Item("YearMonth").ToStr
xVolume.Add(New XElement("Visits", DR.Item("Visits").ToString
End While
End Using
End Using
End Using
Catch ex As Exception
LOG(ex.ToString)
ex = Nothing
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER