Convert XML to CSV in PHP

By David Thomas, at 2014-10-06

Output XML string as CSV with first row as column headers......

Read More   

Latest Tutorials

Sponsored Links
PHP:Convert XML to CSV in PHP.....
PHP:PHP code to write to a CSV fil.....
PHP:PHP code to write to a CSV fil.....
PHP:PHP code to import from CSV fi.....
PHP:Password must include both num.....
Trends:What is Hadoop?.....
WebServices:Returning multiple values from.....
Java:Tomcat and httpd configured in.....
WebServices:Java Webservices using Netbean.....
WebServices:Java WebService connected to D.....
WebServices:How to Deploy a Java Web Servi.....
WebServices:Call a webservice in Java.....
WebServices:Java WebService - Create your .....
WebServices:package javax.jws does not exi.....
Reviews:Nokia Lumia 620 and Samsung AT.....
Reviews:The Twist and Yoga Ultrabooks.....
Android:Getting Started with Android.....
Reviews:Samsung Galaxy S4.....
Reviews:Samsung Galaxy Note 8.0.....

Latest Comments

1. View Comment

' REFERENCIA EN EL PROYECTO (Microsoft Excel 12.0 Object Library)
' BUSCARLA EN PESTAÑA COM (C:Program Files (x86)Microsoft OfficeOffice12EXCEL>EXE)


Imports Excel = Microsoft.Office.Interop.Excel Imports Microsoft.Vbe.Interop

Public Class Form1

Sub DATAGRIDVIEW_TO_EXCEL(ByVal DGV As DataGridView)
Try
Dim DTB = New DataTable, RWS As Integer, CLS As Integer

For CLS = 0 To DGV.ColumnCount - 1
DTB.Columns.Add(DGV.Columns(CLS).Name.ToString)
Next

Dim DRW As DataRow

For RWS = 0 To DGV.Rows.Count - 1
DRW = DTB.NewRow

For CLS = 0 To DGV.ColumnCount - 1
If DGV.Columns(CLS).Visible = True Then
Try
DRW(DTB.Columns(CLS).ColumnName.ToString) = DGV.Rows(RWS).Cells(CLS).Value.ToString
Catch ex As Exception

End Try
End If
Next

DTB.Rows.Add(DRW)
Next

DTB.AcceptChanges()

Dim DST As New DataSet
DST.Tables.Add(DTB)
DTB.WriteXml("C:MMS FILESRESOURCESXML.xml") ' SE CREA UN XML CON LA INFO DEL DATAGRIDVIEW
MACRO("C:MMS FILESRESOURCESXML.xml") ' Y ESTE PROCEDIMIENTO LO ABRE EN EXCEL

Catch ex As Exception
MsgBox(ex.ToString)
End Try

End Sub

Private Sub MACRO(ByVal FLE As String)
Try
Dim xlApp As Object = New Microsoft.Office.Interop.Excel.Application

Try ' OPCIONALMENTE LE DAS TAMAÑO A TU APLICACION DE EXCEL
xlApp.Left = 250
xlApp.Top = 100
xlApp.Width = 900
xlApp.Height = 550
Catch ex As Exception
' PROTEGIENDO EL PROCESO SI LA ULTIMA APLICACION FUE EN FULL SCREEN
End Try

Dim xlWb As Excel.Workbook = xlApp.Workbooks.Add ' AGREGAS TU LIBRO DE EXCEL

Dim MT As Integer ' Y OPCIONALMENTE LE DAS ESTILO Y FORMATO A SUS 3 HOJAS

For MT = 3 To 1 Step -1
xlWb.Sheets(MT).Select()
xlWb.Sheets(MT).cells.select()
xlWb.Sheets(MT).cells.Font.Name = "Arial"
xlWb.Sheets(MT).cells.Font.Size = 8
xlWb.Sheets(MT).cells.Font.bold = True
xlWb.Sheets(MT).Range("A1").Select()
Next

' LE CREAS UN MODULO LO NOMBRAS Y LE AGREGAS UNA MACRO DE ARRANQUE AL ABRIR

Dim xlMod As Microsoft.Vbe.Interop.VBComponent = xlWb.VBProject.VBComponents.Add(Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_StdModule)
xlMod.Name = "Module1"

Dim macroCode As String = _
"Public Sub Main()" & vbCrLf & _
" ActiveWorkbook.XmlImport URL:=" & Chr(34) & FLE & Chr(34) & ", ImportMap:=Nothing, Overwrite:=True, Destination:=Range(" & Chr(34) & "$A$1" & Chr(34) & ")" & vbCrLf & _
" ActiveSheet.ListObjects(" & Chr(34) & "Table1" & Chr(34) & ").TableStyle = " & Chr(34) & "TableStyleMedium12" & vbCrLf & _
" Sheet1.Range(" & Chr(34) & "A2" & Chr(34) & ").Select" & vbCrLf & _
" ActiveWindow.FreezePanes = True" & vbCrLf & _
"End Sub"

xlMod.CodeModule.AddFromString(macroCode)

xlApp.Visible = True
xlApp.Application.Run("Main")

' OPCIONALMENTE (RECOMENDADO DIRIA YO) BORRAS TU MODULO SALVO QUE QUIERAS VERLO DURANTE LAS PRUEBAS

Dim MDL As Object = xlApp.Application.VBE.ActiveVBProject.VBComponents
MDL.Remove(VBComponent:=MDL.Item("Module1"))

' Y CIERRAS ESTE PROCEDIMIENTO LIBERANDO LAS VARIABLES

ReleaseObject(xlApp)
ReleaseObject(xlMod)
ReleaseObject(xlWb)
ReleaseObject(MDL)

Catch ex As Exception
MsgBox(ex.ToString())
End Try

End Sub

Private Sub ReleaseObject(ByVal OBJ As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(OBJ)
Catch ex As Exception

End Try

OBJ = Nothing
GC.Collect()
End Sub

End Class

View Tutorial          By: Anonymous at 2015-04-21 03:10:41
2. View Comment

Hi Shiva,
Comparator interface is used to order the objects of user-defined class.
For Example:
public int compare(Object obj1,Object obj2): compares the first object with second object.

View Tutorial          By: Srinath at 2015-04-19 08:23:20
3. View Comment

what we have to write in simple comparator class can u explain in briefly thank you

View Tutorial          By: shiva at 2015-04-18 09:19:17
4. View Comment

Very Nice and Perfectly Understandable.....

View Tutorial          By: rex at 2015-04-16 12:27:03
5. View Comment

hi this is from Ashok....
can you send the source code for sending and receiving from computer through local net work.send to my email id.... dhamerlaashok16@gmail.com

View Tutorial          By: Ashok at 2015-04-16 11:51:51
6. View Comment

Unable to understand all the points, quiet confusing.

View Tutorial          By: KB at 2015-04-15 10:11:14
7. View Comment

great explanations.. some important words are missing for example... calling itself REPEATED... there is no repeat word... so that it may recursive

View Tutorial          By: Joshua Paul at 2015-04-14 03:43:44

More Latest News
Most Viewed Articles (in last 30 days)
Most Emailed Articles (in last 30 days)