Imports System.Xml
Public Class Form1
Public archivo As String = "cfg.xml"
Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
Dim doc As New XmlDocument
doc.Load(archivo)
Dim tablas As XmlNodeList = doc.SelectNodes("/Data/TCV/tabla") ' cargar tablas
Dim campos As XmlNodeList = doc.SelectNodes("/Data/TCV/campo/id") ' cargar todos los campos
For Each x As XmlNode In campos
MessageBox.Show(x.InnerXml)
Next
End Sub
Private Sub btnvervar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvervar.Click
Dim campo As String = "test2"
Dim doc As New XmlDocument
doc.Load(archivo)
Dim nodes As XmlNodeList = doc.SelectNodes("/Data/TCV")
For Each x As XmlNode In nodes
Dim nodevar As XmlNodeList = x.SelectNodes("campo/id")
For Each node As XmlNode In nodevar
If node.InnerXml = campo Then
Dim var As XmlNodeList = node.ParentNode.SelectNodes("variables/var")
For Each elem As XmlNode In var
MessageBox.Show(elem.InnerXml)
Next
Exit For
End If
Next
Next
End Sub
Private Sub btneliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btneliminar.Click
Dim tabla As String = "DoctosFE"
Dim doc As New XmlDocument
doc.Load(archivo)
Dim xpath As String = "/Data/TCV[tabla=""" & tabla & """]"
Dim del As XmlElement = doc.SelectSingleNode(xpath)
del.ParentNode.RemoveChild(del)
doc.Save(archivo)
End Sub
No hay comentarios.:
Publicar un comentario