Hello, I'm using the following code to create an XML file from a dataset. The file is created but the formatting is not what I need. How can I get my XML file to look like this:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<gallery timer="5" order="random" fadetime="2" looping="yes" xpos="0" ypos="0">
<image path="Images/one.jpg" />
<image path="Images/two.jpg" />
<image path="Images/three.jpg" />
<image path="Images/four.jpg" />
<image path="Images/five.jpg" />
</gallery>
WITH THE CODE BELOW it comes out like this:
<?xml version="1.0" standalone="yes"?>
<gallery>
<path path="Photos/one.jpg" />
<path path="Photos/two.jpg" />
<path path="Photos/three.jpg" />
<path path="Photos/four.jpg" />
<path path="Photos/five.jpg" />
</gallery>
SO naturally it does not work:
How can I modify my code below to obtain the first xml example???
Try
Dim objConn As SqlConnection = New SqlConnection(System.Confi
guration.C
onfigurati
onManager.
Connection
Strings("S
BD").ToStr
ing)
Dim objDS As New DataSet
'<gallery timer="5" order="random" fadetime="2" looping="yes" xpos="0" ypos="0">
objDS.DataSetName = "gallery"
Dim objaCmd As SqlCommand = New SqlCommand("Meyers_Get_Hom
ePagePhoto
s", objConn)
objaCmd.CommandType = CommandType.StoredProcedur
e
Dim objaDA As New SqlDataAdapter(objaCmd)
objConn.Open()
objaDA.Fill(objDS, "path")
objConn.Close()
Dim path As DataColumn
For Each path In objDS.Tables("path").Colum
ns
path.ColumnMapping = MappingType.Attribute
Next
objDS.WriteXml(Server.MapP
ath("Image
s.xml"), XmlWriteMode.IgnoreSchema)
Catch ex As SqlException
lblMessage.Text = ex.ToString()
End Try
Start Free Trial