ajaac
asked on
Problem creating an XML file form a datatable
I'm missing something that I've spent the last few hours stuck on, hopefully someone can point me in the right direction.
I'm trying to create an xml document to be opened later by excel.
I can do this with dataset.writexml, but I only want one table written to the xml file.
I get an error on this line.
rootElement.AppendChild(ro wElement)
The error is Object reference not set to an instance of an object.
Exception Details: System.NullReferenceExcept ion: Object reference not set to an instance of an object.
I suspect the problem to be with this line.
Dim rootElement As XmlElement = doc.DocumentElement
I just don't see what i need to do to get this to work.
Code
Dim dsBrowse As DataSet = CType(Session("dsBrowse"), DataSet)
Dim strFilename As String
strFilename = "C:\Customers2.xml"
Dim dt As New DataTable
Dim row As DataRow
Dim rowElement As XmlElement
dt = dsBrowse.Tables("tblContac t")
Dim doc As XmlDocument = New XmlDocument
Dim xw As XmlTextWriter = New XmlTextWriter(strFilename, System.Text.Encoding.UTF8)
Dim rootElement As XmlElement = doc.DocumentElement()
Dim i As Integer, cnt As Long
Dim colElement(dt.Columns.Coun t) As XmlElement
xw.WriteProcessingInstruct ion("xml", "version='1.0'")
xw.WriteProcessingInstruct ion("mso-a pplication ", "progid='Excel.Sheet'")
For Each row In dt.Rows
rowElement = doc.CreateElement("Table")
For i = 0 To dt.Columns.Count - 1
colElement(i) = doc.CreateElement(dt.Colum ns(i).Capt ion)
colElement(i).InnerText = row(i).ToString()
rowElement.AppendChild(col Element(i) )
Next i
rootElement.AppendChild(ro wElement)
Next
doc.WriteTo(xw)
xw.Close()
I'm trying to create an xml document to be opened later by excel.
I can do this with dataset.writexml, but I only want one table written to the xml file.
I get an error on this line.
rootElement.AppendChild(ro
The error is Object reference not set to an instance of an object.
Exception Details: System.NullReferenceExcept
I suspect the problem to be with this line.
Dim rootElement As XmlElement = doc.DocumentElement
I just don't see what i need to do to get this to work.
Code
Dim dsBrowse As DataSet = CType(Session("dsBrowse"),
Dim strFilename As String
strFilename = "C:\Customers2.xml"
Dim dt As New DataTable
Dim row As DataRow
Dim rowElement As XmlElement
dt = dsBrowse.Tables("tblContac
Dim doc As XmlDocument = New XmlDocument
Dim xw As XmlTextWriter = New XmlTextWriter(strFilename,
Dim rootElement As XmlElement = doc.DocumentElement()
Dim i As Integer, cnt As Long
Dim colElement(dt.Columns.Coun
xw.WriteProcessingInstruct
xw.WriteProcessingInstruct
For Each row In dt.Rows
rowElement = doc.CreateElement("Table")
For i = 0 To dt.Columns.Count - 1
colElement(i) = doc.CreateElement(dt.Colum
colElement(i).InnerText = row(i).ToString()
rowElement.AppendChild(col
Next i
rootElement.AppendChild(ro
Next
doc.WriteTo(xw)
xw.Close()
ASKER
I know I could do it that way, but I would perfer to get the code I posted to work.
To understand what I'm missing, and as my perferred method to address this issue.
To understand what I'm missing, and as my perferred method to address this issue.
You set the root element to the DocumentElement, which is not set. You need to call CreateElement to add a single root element.
Bob
Bob
ASKER
TheLearnedOne, can you provide sample code so I know where and how to do this? What I just tried did not work.
Are you trying to create an Excel XML file?
Bob
Bob
ASKER
Yes, but more importantly I want to know why I cannot get my code to work.
Your reply to create a root element is what I'm stuck on right now, how do I do that?
Your reply to create a root element is what I'm stuck on right now, how do I do that?
ASKER
I got the code to work by changing the line.
Dim rootElement As XmlElement = doc.DocumentElement()
to
Dim rootElement As XmlElement = doc.CreateElement("Contact ")
Now I need to get the format right for excel, if you have any suggestions, I would appreciate it.
Thanks
Dim rootElement As XmlElement = doc.DocumentElement()
to
Dim rootElement As XmlElement = doc.CreateElement("Contact
Now I need to get the format right for excel, if you have any suggestions, I would appreciate it.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Worker class for Excel--ExcelWorkbook:
Imports System.IO
Imports System.Xml
Imports System.Text
Imports System.Reflection
Imports System.Security.Cryptograp hy.Xml
' Xml Reference:
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xlsmlinss.asp
Public Class ExcelWorkbook
Private m_listWorksheets As New ArrayList
Private m_document As XmlDocument
Private m_bookTemplate As XmlNode
Private m_sheetTemplate As XmlNode
Private m_tableTemplate As XmlNode
Private m_rowTemplate As XmlNode
Private m_cellTemplate As XmlNode
Private m_nsmgr As XmlNamespaceManager
Private m_isFirstWorksheet As Boolean = True
Public Sub New()
m_document = New XmlDocument
m_document.LoadXml(Me.GetX mlTemplate ("Workbook .xml"))
m_nsmgr = New XmlNamespaceManager(m_docu ment.NameT able)
For Each attr As XmlAttribute In m_document.SelectSingleNod e("/*").At tributes
If attr.Prefix = "xmlns" Then
m_nsmgr.AddNamespace(attr. LocalName, attr.Value)
End If
Next attr
m_bookTemplate = m_document.SelectSingleNod e("//ss:Wo rkbook", m_nsmgr).Clone()
If m_bookTemplate Is Nothing Then
Throw New ArgumentNullException("Wor kbook", "Workbook not found")
End If
m_sheetTemplate = m_document.SelectSingleNod e("//ss:Wo rksheet", m_nsmgr).Clone()
If m_sheetTemplate Is Nothing Then
Throw New ArgumentNullException("Wor ksheet", "Worksheet not found")
End If
m_tableTemplate = m_document.SelectSingleNod e("//ss:Ta ble", m_nsmgr).Clone()
If m_tableTemplate Is Nothing Then
Throw New ArgumentNullException("Tab leTemplate ", "Table template not found")
End If
m_rowTemplate = m_tableTemplate.SelectSing leNode("// ss:Row", m_nsmgr).Clone()
If m_rowTemplate Is Nothing Then
Throw New ArgumentNullException("Row Template", "Row template not found")
End If
m_cellTemplate = m_rowTemplate.SelectSingle Node("//ss :Cell", m_nsmgr).Clone()
If m_cellTemplate Is Nothing Then
Throw New ArgumentNullException("Cel lTemplate" , "Cell template not found")
End If
End Sub 'New
Public ReadOnly Property Xml() As String
Get
Dim book As XmlNode = m_document.SelectSingleNod e("//ss:Wo rkbook", m_nsmgr)
Dim sheet As XmlNode = book.SelectSingleNode("//s s:Workshee t", m_nsmgr)
For Each node As XmlNode In m_listWorksheets
book.InsertAfter(node, sheet)
Next node
book.RemoveChild(sheet)
Dim transformer As New XmlDsigC14NTransform
transformer.LoadInput(m_do cument)
Dim strm As Stream = transformer.GetOutput(GetT ype(Stream ))
Dim reader As New StreamReader(strm)
Dim output As String = reader.ReadToEnd()
output = "<?xml version=""1.0""?>" & output
Return output
End Get
End Property 'Xml
Public Sub AddWorksheet(ByVal grid As DataGrid, ByVal name As String)
' Check conditions.
If grid Is Nothing Then
Throw New ArgumentNullException("Gri d")
End If
If grid.DataSource Is Nothing Then
Throw New ArgumentNullException("Gri d.DataSour ce")
End If
' Get the data source from the data grid.
Dim data As DataTable = CType(grid.DataSource, DataSet).Tables(0)
' Copy the Worksheet element.
Dim sheet As XmlNode = m_sheetTemplate.Clone()
sheet.Attributes("ss:Name" ).Value = name
' Copy the Table element.
Dim table As XmlNode = m_tableTemplate.Clone()
' Remove the Row and Cell elements.
table.RemoveChild(table.Ch ildNodes(0 ))
' Add Row and Cell elements to the Table.
Me.AddRows(grid, table, data)
If m_isFirstWorksheet Then
' Remove the table, rows, cells, etc. from the template.
m_sheetTemplate.RemoveChil d(m_sheetT emplate.Ch ildNodes(0 ))
m_isFirstWorksheet = False
End If
' Add the Table to the Worksheet.
sheet.InnerXml = table.OuterXml
' Add the Worksheet to the list.
m_listWorksheets.Add(sheet )
End Sub 'AddWorksheet
Private Sub AddRows(ByVal grid As DataGrid, ByVal tableNode As XmlNode, _
ByVal table As DataTable)
Dim buildRow As New StringBuilder(2000)
Dim index As Integer
Dim cell As XmlNode
Dim data As XmlNode
buildRow.Append(Me.AddColu mns(grid))
For Each row As DataRow In table.Rows
Dim node As XmlNode = m_rowTemplate.Clone()
Dim buildCells As New StringBuilder(1000)
For index = 0 To grid.Columns.Count - 1
cell = m_cellTemplate.Clone()
data = cell.SelectSingleNode("ss: Data", m_nsmgr)
Dim gridColumn As DataGridColumn = grid.Columns(index)
If TypeOf gridColumn Is BoundColumn AndAlso gridColumn.Visible Then
Dim columnName As String = Me.FindColumnName(gridColu mn)
Dim column As DataColumn = table.Columns(columnName)
Dim type As String = column.DataType.Name
Dim value As String = row(columnName).ToString()
If value.Length > 0 Then
Dim cellStyle As String = Me.DataTypeToStyleID(type)
' Set the cell style.
cell.Attributes("ss:StyleI D").Value = cellStyle
data.Attributes("ss:Type") .Value = type
data.InnerText = value
Else
cell.RemoveChild(cell.Sele ctSingleNo de("ss:Dat a", m_nsmgr))
End If
' Add the cell to the row.
buildCells.Append(cell.Out erXml)
End If
Next index
node.InnerXml = buildCells.ToString()
buildRow.Append(node.Outer Xml)
Next row
tableNode.InnerXml = buildRow.ToString()
End Sub 'AddRows
Private Function DataTypeToStyleID(ByRef type As String) As String
Dim cellStyle As String = type
' Convert the data type to a cell style
Select Case cellStyle
Case "String"
cellStyle = "Text"
Case "DateTime"
cellStyle = "Date"
Case "Double", "Single", "Decimal"
cellStyle = "Number"
type = "Number"
Case "Integer", "Short", "Byte", "Int32", "Int16"
cellStyle = "Number"
type = "Number"
Case Else
Throw New ArgumentException("Unknown data type: " & type)
End Select 'cellStyle
Return cellStyle
End Function
Private Function FindColumnName(ByVal gridColumn As DataGridColumn) As String
If TypeOf gridColumn Is BoundColumn Then
Dim column As BoundColumn = gridColumn
Return column.DataField
End If
End Function 'FindColumnName
Private Function AddColumns(ByVal grid As DataGrid) As String
Dim gridColumn As DataGridColumn
Dim node As XmlNode = m_rowTemplate.Clone()
Dim buildCells As New StringBuilder(1000)
For index As Integer = 0 To grid.Columns.Count - 1
gridColumn = grid.Columns(index)
Dim cell As XmlNode = m_cellTemplate.Clone()
Dim data As XmlNode = cell.SelectSingleNode("ss: Data", m_nsmgr)
cell.Attributes("ss:StyleI D").Value = "Text"
data.Attributes("ss:Type") .Value = "String"
data.InnerText = gridColumn.HeaderText
' Add the cell to the row.
buildCells.Append(cell.Out erXml)
Next index
node.InnerXml = buildCells.ToString()
Return node.OuterXml
End Function 'AddColumns
Private Function GetXmlTemplate(ByVal fileName As String) As String
Dim stream As Stream
Dim reader As StreamReader
Dim xml As String = ""
Try
Dim assy As [Assembly] = [Assembly].GetExecutingAss embly()
For Each name As String In assy.GetManifestResourceNa mes()
If name.IndexOf(fileName) <> -1 Then
stream = assy.GetManifestResourceSt ream(name)
End If
Next name
reader = New StreamReader(stream)
xml = reader.ReadToEnd()
Catch ex As Exception
Throw
Finally
If Not stream Is Nothing Then
stream.Close()
End If
If Not reader Is Nothing Then
reader.Close()
End If
End Try
Return xml
End Function 'GetXmlTemplate
End Class
Imports System.IO
Imports System.Xml
Imports System.Text
Imports System.Reflection
Imports System.Security.Cryptograp
' Xml Reference:
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xlsmlinss.asp
Public Class ExcelWorkbook
Private m_listWorksheets As New ArrayList
Private m_document As XmlDocument
Private m_bookTemplate As XmlNode
Private m_sheetTemplate As XmlNode
Private m_tableTemplate As XmlNode
Private m_rowTemplate As XmlNode
Private m_cellTemplate As XmlNode
Private m_nsmgr As XmlNamespaceManager
Private m_isFirstWorksheet As Boolean = True
Public Sub New()
m_document = New XmlDocument
m_document.LoadXml(Me.GetX
m_nsmgr = New XmlNamespaceManager(m_docu
For Each attr As XmlAttribute In m_document.SelectSingleNod
If attr.Prefix = "xmlns" Then
m_nsmgr.AddNamespace(attr.
End If
Next attr
m_bookTemplate = m_document.SelectSingleNod
If m_bookTemplate Is Nothing Then
Throw New ArgumentNullException("Wor
End If
m_sheetTemplate = m_document.SelectSingleNod
If m_sheetTemplate Is Nothing Then
Throw New ArgumentNullException("Wor
End If
m_tableTemplate = m_document.SelectSingleNod
If m_tableTemplate Is Nothing Then
Throw New ArgumentNullException("Tab
End If
m_rowTemplate = m_tableTemplate.SelectSing
If m_rowTemplate Is Nothing Then
Throw New ArgumentNullException("Row
End If
m_cellTemplate = m_rowTemplate.SelectSingle
If m_cellTemplate Is Nothing Then
Throw New ArgumentNullException("Cel
End If
End Sub 'New
Public ReadOnly Property Xml() As String
Get
Dim book As XmlNode = m_document.SelectSingleNod
Dim sheet As XmlNode = book.SelectSingleNode("//s
For Each node As XmlNode In m_listWorksheets
book.InsertAfter(node, sheet)
Next node
book.RemoveChild(sheet)
Dim transformer As New XmlDsigC14NTransform
transformer.LoadInput(m_do
Dim strm As Stream = transformer.GetOutput(GetT
Dim reader As New StreamReader(strm)
Dim output As String = reader.ReadToEnd()
output = "<?xml version=""1.0""?>" & output
Return output
End Get
End Property 'Xml
Public Sub AddWorksheet(ByVal grid As DataGrid, ByVal name As String)
' Check conditions.
If grid Is Nothing Then
Throw New ArgumentNullException("Gri
End If
If grid.DataSource Is Nothing Then
Throw New ArgumentNullException("Gri
End If
' Get the data source from the data grid.
Dim data As DataTable = CType(grid.DataSource, DataSet).Tables(0)
' Copy the Worksheet element.
Dim sheet As XmlNode = m_sheetTemplate.Clone()
sheet.Attributes("ss:Name"
' Copy the Table element.
Dim table As XmlNode = m_tableTemplate.Clone()
' Remove the Row and Cell elements.
table.RemoveChild(table.Ch
' Add Row and Cell elements to the Table.
Me.AddRows(grid, table, data)
If m_isFirstWorksheet Then
' Remove the table, rows, cells, etc. from the template.
m_sheetTemplate.RemoveChil
m_isFirstWorksheet = False
End If
' Add the Table to the Worksheet.
sheet.InnerXml = table.OuterXml
' Add the Worksheet to the list.
m_listWorksheets.Add(sheet
End Sub 'AddWorksheet
Private Sub AddRows(ByVal grid As DataGrid, ByVal tableNode As XmlNode, _
ByVal table As DataTable)
Dim buildRow As New StringBuilder(2000)
Dim index As Integer
Dim cell As XmlNode
Dim data As XmlNode
buildRow.Append(Me.AddColu
For Each row As DataRow In table.Rows
Dim node As XmlNode = m_rowTemplate.Clone()
Dim buildCells As New StringBuilder(1000)
For index = 0 To grid.Columns.Count - 1
cell = m_cellTemplate.Clone()
data = cell.SelectSingleNode("ss:
Dim gridColumn As DataGridColumn = grid.Columns(index)
If TypeOf gridColumn Is BoundColumn AndAlso gridColumn.Visible Then
Dim columnName As String = Me.FindColumnName(gridColu
Dim column As DataColumn = table.Columns(columnName)
Dim type As String = column.DataType.Name
Dim value As String = row(columnName).ToString()
If value.Length > 0 Then
Dim cellStyle As String = Me.DataTypeToStyleID(type)
' Set the cell style.
cell.Attributes("ss:StyleI
data.Attributes("ss:Type")
data.InnerText = value
Else
cell.RemoveChild(cell.Sele
End If
' Add the cell to the row.
buildCells.Append(cell.Out
End If
Next index
node.InnerXml = buildCells.ToString()
buildRow.Append(node.Outer
Next row
tableNode.InnerXml = buildRow.ToString()
End Sub 'AddRows
Private Function DataTypeToStyleID(ByRef type As String) As String
Dim cellStyle As String = type
' Convert the data type to a cell style
Select Case cellStyle
Case "String"
cellStyle = "Text"
Case "DateTime"
cellStyle = "Date"
Case "Double", "Single", "Decimal"
cellStyle = "Number"
type = "Number"
Case "Integer", "Short", "Byte", "Int32", "Int16"
cellStyle = "Number"
type = "Number"
Case Else
Throw New ArgumentException("Unknown
End Select 'cellStyle
Return cellStyle
End Function
Private Function FindColumnName(ByVal gridColumn As DataGridColumn) As String
If TypeOf gridColumn Is BoundColumn Then
Dim column As BoundColumn = gridColumn
Return column.DataField
End If
End Function 'FindColumnName
Private Function AddColumns(ByVal grid As DataGrid) As String
Dim gridColumn As DataGridColumn
Dim node As XmlNode = m_rowTemplate.Clone()
Dim buildCells As New StringBuilder(1000)
For index As Integer = 0 To grid.Columns.Count - 1
gridColumn = grid.Columns(index)
Dim cell As XmlNode = m_cellTemplate.Clone()
Dim data As XmlNode = cell.SelectSingleNode("ss:
cell.Attributes("ss:StyleI
data.Attributes("ss:Type")
data.InnerText = gridColumn.HeaderText
' Add the cell to the row.
buildCells.Append(cell.Out
Next index
node.InnerXml = buildCells.ToString()
Return node.OuterXml
End Function 'AddColumns
Private Function GetXmlTemplate(ByVal fileName As String) As String
Dim stream As Stream
Dim reader As StreamReader
Dim xml As String = ""
Try
Dim assy As [Assembly] = [Assembly].GetExecutingAss
For Each name As String In assy.GetManifestResourceNa
If name.IndexOf(fileName) <> -1 Then
stream = assy.GetManifestResourceSt
End If
Next name
reader = New StreamReader(stream)
xml = reader.ReadToEnd()
Catch ex As Exception
Throw
Finally
If Not stream Is Nothing Then
stream.Close()
End If
If Not reader Is Nothing Then
reader.Close()
End If
End Try
Return xml
End Function 'GetXmlTemplate
End Class
ExcelWorkbook.GetXmlTempla te retrieves template text from an embedded XML file (Name = Workbook.xml, Build Action = 'Embedded Resource'):
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microso ft-com:off ice:spread sheet"
xmlns:o="urn:schemas-micro soft-com:o ffice:offi ce"
xmlns:x="urn:schemas-micro soft-com:o ffice:exce l"
xmlns:ss="urn:schemas-micr osoft-com: office:spr eadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microso ft-com:off ice:office ">
<Author></Author>
<LastAuthor></LastAuthor>
<Created></Created>
<Company>WPAFB</Company>
<Version></Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microso ft-com:off ice:excel" >
<WindowHeight>8190</Window Height>
<WindowWidth>11400</Window Width>
<WindowTopX>360</WindowTop X>
<WindowTopY>120</WindowTop Y>
<ActiveSheet>1</ActiveShee t>
<ProtectStructure>False</P rotectStru cture>
<ProtectWindows>False</Pro tectWindow s>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Tahoma"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="Text">
<Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
<NumberFormat ss:Format="@"/>
</Style>
<Style ss:ID="Date">
<Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
<NumberFormat ss:Format="Short Date"/>
</Style>
<Style ss:ID="Number">
<Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
<NumberFormat ss:Format="0;[Red]0"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table>
<Row>
<Cell ss:StyleID="Text"><Data ss:Type="String">1:A1</Dat a></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microso ft-com:off ice:excel" >
<Panes>
</Panes>
<ProtectObjects>False</Pro tectObject s>
<ProtectScenarios>False</P rotectScen arios>
</WorksheetOptions>
</Worksheet>
</Workbook>
<!--
<Cell ss:StyleID="Numeric"><Data ss:Type="Number">12.34</Da ta></Cell>
<Cell ss:StyleID="Date"><Data ss:Type="DateTime">2006-12 -12T00:00: 00.000</Da ta></Cell>
-->
Bob
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microso
xmlns:o="urn:schemas-micro
xmlns:x="urn:schemas-micro
xmlns:ss="urn:schemas-micr
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microso
<Author></Author>
<LastAuthor></LastAuthor>
<Created></Created>
<Company>WPAFB</Company>
<Version></Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microso
<WindowHeight>8190</Window
<WindowWidth>11400</Window
<WindowTopX>360</WindowTop
<WindowTopY>120</WindowTop
<ActiveSheet>1</ActiveShee
<ProtectStructure>False</P
<ProtectWindows>False</Pro
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Tahoma"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="Text">
<Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
<NumberFormat ss:Format="@"/>
</Style>
<Style ss:ID="Date">
<Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>
<NumberFormat ss:Format="Short Date"/>
</Style>
<Style ss:ID="Number">
<Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
<NumberFormat ss:Format="0;[Red]0"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table>
<Row>
<Cell ss:StyleID="Text"><Data ss:Type="String">1:A1</Dat
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microso
<Panes>
</Panes>
<ProtectObjects>False</Pro
<ProtectScenarios>False</P
</WorksheetOptions>
</Worksheet>
</Workbook>
<!--
<Cell ss:StyleID="Numeric"><Data
<Cell ss:StyleID="Date"><Data ss:Type="DateTime">2006-12
-->
Bob
Dim DataSet2 As DataSet = DataSet1.Copy()
DataSet2.Tables.Remove("Ta
DataSet2.WriteXml("C:\temp
Bob