, how would I change 'Tom' to something else, plus I also need to check the gender !!
Also it should loop through all XML !!
How can I do this ??
Are you using it as a database?
Anyway
[php]
Dim root As XElement = XElement.Load("Location\Filename.xml")
Dim xt As XElement = (From el In root.Descendants("Node1") _
Select el).First()
xt.SetValue("New Value")
root.Save("Location\Filename.xml")
[/php]
You can do this dynamically as well by using the value fields with combo-box data or textbox values, etc.
In asp.net/vb.net/c# I bind XML's as databases all the time, much more convenient then a database, and I don't have to worry to much about
truncating or overloads
Originally Posted by NextGen1
Are you using it as a database?
Anyway
[php]
Dim root As XElement = XElement.Load("Location\Filename.xml")
Dim xt As XElement = (From el In root.Descendants("Node1") _
Select el).First()
xt.SetValue("New Value")
root.Save("Location\Filename.xml")
[/php]
You can do this dynamically as well by using the value fields with combo-box data or textbox values, etc.
In asp.net/vb.net/c# I bind XML's as databases all the time, much more convenient then a database, and I don't have to worry to much about
truncating or overloads
Yup, a simple database (not more than 10000 items).
I know XML serialization in .net is blazing fast, that's why I chose it
And thnx for the help, I know another way (Googled) but its harder. I wanted simple and its simple enough
Any guidance for creating a database using XML plz ??
Ill create a tut and post it, give me 5 mins or so
----------Code MSDN Standard, Not mine, just collected for sharing.
Datagrid
[php]
Private Sub lbTables_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim tblName As String = lbTables.Text
currentTable = dataSet.Tables(tblName)
ShowColumns()
dgData.SetDataBinding(dataSet, tblName)
dgData.CaptionText = "Table: " & tblName
End Sub
[/php]
Load an XML File (using Open Dialog() Modify to hard code database.
[php]
Dim res As DialogResult = openFileDialog.ShowDialog(Me)
If res = DialogResult.OK Then
Dim fn As String = openFileDialog.FileName
Dim ds As New DataSet()
ds.ReadXml(fn)
lbTables.Items.Clear()
For Each dt As DataTable In ds.Tables
lbTables.Items.Add(dt.TableName)
Next
dataSet = ds
lbTables.SelectedIndex = 0
fnSchema = fn
Me.Text = "XML Database Editor - " & fnSchema
End if
[php]
Dim tblName As String = edTableName.Text
If Not ValidateTableName(tblName) Then
Exit Sub
End If
Dim dt As New DataTable(tblName)
currentTable = dt
lbTables.Items.Add(tblName)
dataSet.Tables.Add(dt)
lbTables.SelectedItem = lbTables.Items(lbTables.FindStringExact(tblName))
[/php]
Add column
[php]
Dim colName As String = edColumnName.Text
Dim colType As String = cbColumnType.Text
If (Not ValidateColumnNameAndType(colName, colType)) OrElse (Not ValidateSelectedTable()) Then
Exit Sub
End If
Dim lvi As ListViewItem = lvColumns.Items.Add(colName)
lvi.SubItems.Add(colType)
currentTable.Columns.Add(colName, Type.[GetType]("System." & colType))
[/php]
Display Columns
[php]
lvColumns.Items.Clear()
If currentTable IsNot Nothing Then
For Each dc As DataColumn In currentTable.Columns
Dim lvi As ListViewItem = lvColumns.Items.Add(dc.ColumnName)
Dim s As String = dc.DataType.ToString()
s = s.Split(New [Char]() {"."c})(1)
lvi.SubItems.Add(s)
Next
End If
[/php]
How do I use it ?? Which controls are required ??
DataGrid
I left the rest open, those are from button click events, but using the title, (IE open, Edit, Add, Save) you decide what to event triggers the action
Can't find type XElement ??
Code:
Dim root As XElement = XElement.load("Location\Filename.xml")
Imported:
Code:
Imports System.Xml
Imports System.Linq
What's wrong ???
Recently I did a application that required XML , I may have added the references (System.Xml.Linq.dll) so didn't think to show what goes in the namespace, because Mine were already referenced.