将XML文件包含的内容加载到文本框中 [英] Load XML File for what it contains into textboxes

查看:80
本文介绍了将XML文件包含的内容加载到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我快疯了!!!

这是我的情况,我可以编写不带任何问题示例的xml


IM GOING CRAZY !!!

here''s is my situation i can write xml w/o anyproblem example


dim xmlwrt as xmlwriter = xmlwriter.create("C:\sample.xml", settings)

with xmlwrt
.writestartdocument()
.writestartelement("employee")

'Employee Data
.WriteStartElement("FirstName")
.WriteString(nametxt.text.tostring())
.WriteEndElement



姓氏和地址以及雇主卡相同

可以说雇主卡是123456

现在我想创建一个按钮,通过它包含的内容加载"C:\ sample.xml"上的内容


例如:

Textbox1.text ="123456"
Button1 =接受按钮


然后将有关"C:\ sample.xml"的所有信息带回到TextBoxes
名字
姓氏
雇主卡
万一我必须保存它,我只需要更改一些内容,然后再次单击该设计上的保存"按钮,即可将XML与新数据一起保存





same for lastname and address and employer card

lets say the employercard is 123456

now i want to create a BUTTON the load whats on "C:\sample.xml" by what it contains


example:

Textbox1.text = "123456"
Button1 = acceptbutton


then brings all the information is on that "C:\sample.xml" back to the TextBoxes
FirstName
Lastname
employercard
in case the i have to save it i just have to change something and click the button save on that design again to save the XML with the new data



Any help will be great!!!

推荐答案

以下是读取XML文件的方法:
Here is how you could read an XML file:
Dim name as string

Public Sub Load(ByVal p_XMLfilename As String)
       XMLFilename = p_XMLfilename

       Dim x As New System.Xml.XmlDocument
       x.Load(p_XMLfilename)

       Dim x_nodes As System.Xml.XmlNodeList = x.SelectNodes("employee")
       For Each node As System.Xml.XmlNode In x_nodes

           For Each node2 As System.Xml.XmlNode In node
               Select Case node2.Name
                   Case Is = "FirstName" : name = node2.InnerText

               End Select
           Next

       Next
   End Sub


您尝试了什么?您知道如何使用 LINQ to XML [ ^ ]或 XmlDocument [ OpenFileDialog [
What have you tried ? Do you know how to use LINQ to XML[^] or the XmlDocument[^] class to read and parse XML ? Do you know how to use the OpenFileDialog[^] class ?


这篇关于将XML文件包含的内容加载到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆