writexml with root tag

G

Guoqi Zheng

Dear sir,

I am trying to create to writeXml to create a xml file every day.

The WriteXml method of dataset is very nice and easy to use, however, how
can I add the following to my xml file?

<?xml version="1.0" encoding="UTF-8"?>
<productFeed version="0" timestamp="20040105:22:00:05">

Thanks in advanced!!!!
 
N

netnews.comcast.net

This adds a root node to an XML object

Dim N As XmlNode
Dim oXML As New System.Xml.XmlDocument
N = oXML.CreateElement(NodeName)
N.InnerText = Content

This adds an attrbite to the Node represented by N
Dim i As XmlAttribute
i = lXML.CreateAttribute(AttributeName)
i.Value = AttributeText
N.Attributes.SetNamedItem(i)
 
G

Guoqi Zheng

Thanks a lot for your quick reply. Here is my code. where can I put your
code? Sorry, I am very new to .net.


Dim strConnection as String = "Data source=xxx.xxx.xx.xx; Initial
Catalog=vitamincart; User ID=em; Password=pass"
Dim objconnection as New SqlConnection(strConnection)
Dim strSql as String = "SELECT * FROM tblKelkoo"

'Dataadapter setup
Dim objAdapter as New SqlDataAdapter(strSql, objConnection)

'dataset, adapter and table.
Dim objDataSet as New Dataset("Catalog")
objAdapter.fill(objDataset, "Product")


Dim filename As String =
"E:\virtual_hosts\vitaminstore\vitaminstore.nl\home\html\td\product.xml"
' Create the FileStream to write with.
Dim myFileStream As New System.IO.FileStream _
(filename, System.IO.FileMode.Create)
' Write to the file with the WriteXml method.
objDataSet.WriteXml(myFileStream, DiffGram)
myFileStream.Close()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top