digitaldrew
Well-known member
- Joined
- Nov 10, 2012
- Messages
- 167
- Programming Experience
- Beginner
Hello everyone..I hope I can get some help on this. Right now I am sending an API request which has a few strings in it..The request comes back no problem, but it's in XML format.
What I am trying to do is take a part of that response and display it into a log text box. Here is some of my code:
This is only a small peice of it but pretty much everything being used for trying to read the xml and then display it in the textbox..I am only getting a squiggly line error on the last line. That error says "Variable 'result' is used before it has been assigned a value. A null reference exception could result at runtime."
Any idea what I am doing wrong here? Any idea where I could find some good examples for loading an XML file from a string (responsefromserver) and then displaying only a certain chunk of it into a textbox?
Thanks in advance!
What I am trying to do is take a part of that response and display it into a log text box. Here is some of my code:
VB.NET:
Dim responsefromserver As String = reader.ReadToEnd 'is the response coming back from the server
Dim doc As XDocument = XDocument.Load(responsefromserver)
Dim result As String
For Each reply As XElement In doc.<information>
result = reply.<detail>.Value
Next
txtLog.AppendText(name & result & Now & vbCrLf) 'Log file displaying the name and then the result string
This is only a small peice of it but pretty much everything being used for trying to read the xml and then display it in the textbox..I am only getting a squiggly line error on the last line. That error says "Variable 'result' is used before it has been assigned a value. A null reference exception could result at runtime."
Any idea what I am doing wrong here? Any idea where I could find some good examples for loading an XML file from a string (responsefromserver) and then displaying only a certain chunk of it into a textbox?
Thanks in advance!