Private Sub ReadXML(FileLocation As String, FileName As String)
Dim output As StringBuilder = New StringBuilder()
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText(foFile.Text)
' Create an XmlReader
Using reader As XmlReader = XmlReader.Create(New StringReader(fileContents))
Dim attName() As String = {"Name", "North", "East", "Elevation", "Code", _
"Bridge_No", "C_Stab_ft", "Desc", "DiaHt_in", "Dia_in", "DiaWid_in", "Dim_ft", _
"E_Stab_ft", "GrateDimFt", "HDWL_Ht_ft", "Height_ft", "LegLen_ft", "LegWid_ft", _
"Length_ft", "MilePostNo", "N_Stab_ft", "NoBoxes", "Number", "OpenHt_ft", "OpenWid_ft", _
"PaintPanel", "S_Stab_ft", "SigDirectn", "Spread_ft", "Stamping", "Stand_Mast", _
"Type", "TypeDesc", "W_Stab_ft", "Photo"}
'Dim attValue(30) As String
'Check to see if CSV has been created with same name and delete if YES
If My.Computer.FileSystem.FileExists(FileLocation & FileName & ".csv") Then _
My.Computer.FileSystem.DeleteFile(FileLocation & FileName & ".csv")
'Create blank CSV file with same name
Using sw As IO.StreamWriter = New IO.StreamWriter(FileLocation & FileName & ".csv")
'Read the XML
While Not (reader.EOF)
For cCount As Integer = 0 To attName.GetUpperBound(0) Step 1
MsgBox(cCount)
reader.ReadToFollowing(attName(cCount))
MsgBox(attName(cCount) & " = " & reader.ReadElementContentAsString)
If reader.ReadElementContentAsString = "" Then
output.AppendLine(",")
Else
output.AppendLine(reader.ReadElementContentAsString())
End If
cCount = cCount + 1
Next
sw.WriteLine(output.ToString)
End While
End Using
End Using
End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE