Hello
My first post here.
I'm trying to create a dynamic html page from vb.net.
Here is my code. I get the error "'DataTable' is a type and cannot be used as an expression"
Do you know how to solve this :
' Create a new XML document.
Dim xmlDoc As XmlDocument = New XmlDocument
' Create the html tag.
Dim xmlRoot As XmlElement = xmlDoc.CreateElement("html")
xmlDoc.AppendChild(xmlRoot)
' Create the head tag and append it under the html element.
Dim xmlHead As XmlElement = xmlDoc.CreateElement("head")
xmlRoot.AppendChild(xmlHead)
' Create the title tag, set it's text to "Database Table"
' and append it under the head element.
Dim xmlTitle As XmlElement = xmlDoc.CreateElement("title")
xmlTitle.AppendChild(xmlDoc.CreateTextNode("Database Table"))
xmlHead.AppendChild(xmlTitle)
' Create the body element and append it to the root.
Dim xmlBody As XmlElement = xmlDoc.CreateElement("body")
xmlRoot.AppendChild(xmlBody)
' Create the table and append it.
Dim xmlTable As XmlElement = xmlDoc.CreateElement("table")
xmlBody.AppendChild(xmlTable)
' Create the rows.
For Each row As DataRow In DataTable
Dim xmlRow As XmlElement = xmlDoc.CreateElement("tr")
xmlTable.AppendChild(xmlRow)
' Create the cells.
For Each item As Object In row
Dim content As String = ""
If IsDBNull(item) = False Then content = CStr(item)
Dim xmlCell As XmlElement = xmlDoc.CreateElement("td")
xmlCell.AppendChild(xmlDoc.CreateTextNode(content))
xmlRow.AppendChild(xmlCell)
Next
Next