Es erstellt mir die XML wie ich sie will, nur,will ich hier an den Stellen, wo die Variablen Name, Alter, Nachname stehen, die Ergebnisse der Db einfügen, hier der gesamte Code:
Dim vstr = ConfigurationManager.ConnectionStrings("new_Cs").ConnectionString
Dim con As New SqlConnection(vstr)
'SQL Query
Dim sql_name As String = "SELECT name,nachname,alter FROM Personen WHERE Personen.name IS NOT NULL"
Dim data As New SqlDataAdapter(sql_name,con)
Dim ds As DataSet = New DataSet()
data.Fill(ds, "Personen")
Dim varName As String = "stName"
Dim varNachname As String = "stNachname"
Dim varAlta As Integer = 66
Dim wset As New XmlWriterSettings()
wset.Indent = True
wset.NewLineOnAttributes = True
try
Using writer As XmlWriter = XmlWriter.Create("C:\xxx.xml",wset)
writer.WriteStartDocument
writer.WriteStartElement("Personen")
writer.WriteStartElement("Person")
writer.WriteStartAttribute("Nachname")
writer.WriteValue(varNachname) 'Hier den Nachnamen aus der Db
writer.WriteEndAttribute()
writer.WriteStartAttribute("Name")
writer.WriteValue(name) 'Hier den Namen aus der Db
writer.WriteEndAttribute()
writer.WriteStartAttribute("Alta")
writer.WriteValue(varAlta) 'Hier das Alter aus der Db
writer.WriteEndAttribute()
writer.WriteEndElement()
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Flush()
lbl2.Text = "XML-Datei erfolgreich erstellt"
End Using
catch ex As Exception
lbl2.Text = "EEERRROOORR!!!" & ex.Message
End Try
End Sub
ThX