Outline ·
[ Standard ] ·
Linear+
vb.net XML file, how to read from xml
TSWalaweiii
|
Apr 10 2019, 06:12 AM, updated 5y ago
|
New Member
|
this is my code snippet for write..no problem with it For Each i As Integer In number writer.WriteElementString("input" & (i), "10") writer.WriteElementString("input2" & (i), "20") writer.WriteElementString("input3" & (i), "30") writer.WriteElementString("input4" & (i), "40") writer.WriteElementString("input5" & (i), "50") Next
the question is how to read the xml file using one node list and show it in their on textbox?
this is my read code so far
Dim nl As XmlNodeList = c.GetElementsByTagName("input") ...
For Each node As XmlNode In nl textbox1.text(node.InnerText) ... Next node
plus the textbox1.text show red underline..and i dont understand why.
btw this is my first time with xml.
This post has been edited by Walaweiii: Apr 10 2019, 06:14 AM
|
|
|
|
TSWalaweiii
|
Apr 10 2019, 07:33 AM
|
New Member
|
QUOTE(Eventless @ Apr 10 2019, 06:57 AM) Assuming the code with the error is the line above, that is not how you assign a string to a textbox. CODE textbox1.text=node.Innertext Another possible reason is that textbox1 doesn't exist. If you mouse over the red underline, does a message pop up to indicate what the error is? is it like this? txtbox1.Text = Text(node.InnerText) no error shows. but there is not output at the textbox
|
|
|
|
TSWalaweiii
|
Apr 10 2019, 07:55 AM
|
New Member
|
QUOTE(Eventless @ Apr 10 2019, 07:44 AM) Did you read my entire post? The corrected code was already there. Maybe your code isn't returning any value for the textbox to show? Have your tried using a break point to see whether your program actualy reaches the line where your assign the value to your textbox. https://docs.microsoft.com/en-us/visualstudio/debugger/using-breakpoints?view=vs-2019ohh sorry..i mislook at ur code. haven't sleep yet. i use the breakpoint at For Each node As XmlNode In nl and at txtbox1.Text = node.InnerText it shows System.NullReferenceException: 'Object reference not set to an instance of an object.' im not sure if i put the breakpoint at the right place coz i already sleepy af
|
|
|
|