I finally got this code to work wth the below code and the first XML
file, but if I want to use another XML file with a different schema
how can I change my below working code for use with this file:

<?xml version="1.0" encoding="utf-8"?>
<table>
  <row>
    <id>1</id>
    <subject>test1</subject>
    <year>1940</year>
  </row>
  <row>
    <id>2</id>
    <subject>test2</subject>
    <year>1979</year>
  </row>
</table>
_____________________________________________________
Any clues as to the changes to my code to accomodate this new file
schema?

<?xml version="1.0" standalone="yes"?>
<events>
  <topic>
    <eventID>8</eventID>
    <event>testA</event>
    <year>1936</year>
  </topic>
  <topic>
    <eventID>9</eventID>
    <event>testB</event>
    <year>1961</year>
  </topic>
</events>

_________________________________________________________________

 <%@ import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml.XPath" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server">

Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
DataBind()
End Sub

Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As
GridViewEditEventArgs)
Me.GridView1.EditIndex = e.NewEditIndex
bind()
End Sub
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
GridViewUpdateEventArgs)

Dim originalId As String = GridView1.DataKeys
(e.RowIndex).Value.ToString()

Dim id As String = CType(GridView1.Rows(e.RowIndex).Cells(0).Controls
(0), TextBox).Text
Dim subject As String = CType(GridView1.Rows(e.RowIndex).Cells
(1).Controls(0), TextBox).Text
Dim year As String = CType(GridView1.Rows(e.RowIndex).Cells(2).Controls
(0), TextBox).Text

Dim doc As New XmlDocument()
doc.Load(Server.MapPath("history.xml"))

Dim node As XmlNode = doc.SelectSingleNode(("//row[id='" + originalId
+ "']"))

Dim nodeid As XmlNode = node.SelectSingleNode("id")
Dim nodesubject As XmlNode = node.SelectSingleNode("subject")
Dim nodeyear As XmlNode = node.SelectSingleNode("year")

nodeid.InnerText = id
nodesubject.InnerText = subject
nodeyear.InnerText = year

doc.Save(Server.MapPath("history.xml"))
bind()
End Sub
Private Sub bind()
Dim ds As New DataSet()
ds.ReadXml(Server.MapPath("history.xml"))
Me.GridView1.DataSource = ds
GridView1.DataBind()
End Sub 'bind

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

If Not IsPostBack Then
bind()
End If
End Sub 'Page_Load
</script>

Reply via email to