Click here to Skip to main content
15,886,513 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:
XML
<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>


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
Posted
Updated 8-Mar-15 4:00am
v2

You may use XPath Navigation[^] to fullfill your needs.
 
Share this answer
 
Comments
Member 9824751 8-Mar-15 10:17am    
Thanks for the reply, but i just have no idea what i need to change, write and such, to make the code work for me. Could you maybe give me an example of how that code should look like for me?
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
VB
String.Replace(OldChar, NewChar)


If anymore help is required, just ask :|

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

Edit 2, Code:
VB
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.
 
Share this answer
 
v6
Comments
Member 9824751 8-Mar-15 10:33am    
Hey. This sounds like what i'm looking for. Could you maybe make a code example? You don't have to spend ages on it, but it would be nice if you could :) Thanks again
iProgramIt 8-Mar-15 10:35am    
Ok, I'll edit this...
Member 9824751 8-Mar-15 10:57am    
Thank you. I'm a little confused looking at the code, for an example i get an error at the x.text = strLine and the rest too.. Should i replace it with something?
iProgramIt 8-Mar-15 11:06am    
What errors?
iProgramIt 8-Mar-15 11:14am    
Also, the labels will go outside your form, so enable scrollbarsenabled=true

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900