显示.XML文件中的数据 [英] Displaying data from an .XML file

查看:93
本文介绍了显示.XML文件中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

我似乎无法找到任何可以解决这个问题的东西,所以我问你们。我正在尝试使一系列标签显示来自xml文件的一些行。这是一些文件:

Hey,
I can't seem to find anything that could solve this for me, so i ask you guys. I'm trying to make a series of labels display some lines from an xml file. This is some of the file:

<Record>
    <Field column="ID">7</Field>
    <Field column="TEST">HELLO</Field>
    <Field column="IS">True</Field>
    <Field column="POWER">725</Field>
    <Field column="GUID">00000011-01d1-4f7d-af31-6c65c302abe2</Field>
</Record>





这只是整个文件的剪切。这些< Record>< / Record>中有数百个< Record>部分,都具有相同的<字段列...>在他们,但有不同的笔记,这是我想要放入我的6个标签。每个一个。



我对XML文件一无所知,但我在网上找到的东西都无法解决这个问题...



你们有一个如何做到这一点的例子吗?



-nikko4913



This is just a cutout from the whole file. There is hundreds of these <Record></Record> parts, all with the same <Field column...> in them, but with different notes, which is what i want to put into my 6 labels. One for each.

I know nothing about XML files, but nothing of what i found around the web, could solve this...

Do you guys have an example of how i could do this?

-nikko4913

推荐答案

您可以使用 XPath Navigation [ ^ ]以满足您的需求。
You may use XPath Navigation[^] to fullfill your needs.


你可以得到每一行,放入一个文本框,然后为每一行创建一个新的标签,显示xml文件的值和标签(该行的)



或许可以看:

StackOverFlow - 逐行读取文本框的最佳方法

StackOverFlow - 在运行时在vb.net中添加控件或控件(goto sol。 2)



如果您不想制作标签,只需插入文本框即可!



要将标签与标签分开,请使用
You could get each line, put in a textbox and then for each line there is, create a new label displaying the value and the tag of the xml file (of that line)

Perhaps see:
StackOverFlow - Best Way to read a textbox line by line
StackOverFlow - Adding A Control Or Controls In vb.net At Runtime (goto sol. 2)

If you don't want to make labels, just insert into the textbox!

To separate the tag from the label, use
String.Replace(OldChar, NewChar)





如果需要帮助,请询问:|



编辑:

BackGroundWorker如果有数百个条目会有帮助...



编辑2,代码:



If anymore help is required, just ask :|


BackGroundWorker Would Help if there are hundreds of entries...

Edit 2, Code:

textbox.visible=false
textbox.text=my.computer.filesystem.readalltext(FileLocationHere)
For Each strLine As string In textbox.text.split(vbnewline)
Dim prevlocx as integer = 100
Dim x as new label
x.text = strline
x.location = new point(prevlocx, 40)
myform.controls.add(x)
x+=15
Next



如果实现后台工作者你想要。


Implement a background worker if you want to.


这篇关于显示.XML文件中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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