Ok, sorry to be so needy this week! Here is the situation.

I have discovered how to do a linq query to get my data from my xml but when I return it as a string to a list box it is coming in as one large line. No breaks.

Here is the xml:

- <record>
  <jurisdiction>VA Circuit</jurisdiction> 
- <offender>
  <fullname>VARDOS,BENSON</fullname> 
  <dob>01/01/1901</dob> 
  <ssn>123-45-1234</ssn> 
  <sex>MALE</sex> 
  <race>WHITE</race> 
  <haircolor /> 
  <eyecolor>UNKNOWN</eyecolor> 
  <weight>000</weight> 
  <height>000</height> 
  <status /> 
  <address>123 APPLE ST ,RICHMOND VA 23232</address> 
  <casenumber>112233</casenumber> 
  <comments>Offender#: 001 CASE#:112233</comments> 
  <statelinks /> 
  <imagelinks /> 
  <aliases count="0" /> 
  </offender>

Here is the linq query:

ListBox1.Items.Clear()
        Dim feedXML As XDocument = XDocument.Load("c:\mydata.xml")
        Dim sb = New StringBuilder()
        For Each s In (From nbdresponse In feedXML.Descendants("record") _
        Where (nbdresponse.Element("jurisdiction").Value() = Me.DataGridView3.CurrentCell.Value) _
        Select nbdresponse.Elements("offender").Value())
            sb.Append(s)
        Next

        Dim foo = sb.ToString
        ListBox1.Items.Add(foo)

and it is returning:

VARDOS,BENSON01/01/1901123-45-1234MALEWHITEUNKNOWN ..... ETC.

where as I need it to be
VARDOS, BENSON
01/01/1901
123-45-1234
MAIL
WHITE
UNKOWN
ETC.

i am also not apposed to putting this into a gridview as multi rows. But I am lost. Any advice? Any research directions i can take?

Listbox can't take multiline strings unless you owner draw it. Are you trying to list more than one record in the listbox so you can choose or are you just trying to display the info? Just wondering, cause if you're just displaying the info, you want a multiline textbox. Otherwise I would recommend datagridview.

Hi,

I'll admit, I'm very new to VB.net, so this may be a complete waste of your time but......

ListBox1.Items.Clear()
Dim feedXML As XDocument = XDocument.Load("c:\mydata.xml")
Dim sb as string

For Each s In (From nbdresponse In feedXML.Descendants("record") _ 
Where (nbdresponse.Element("jurisdiction").Value() = Me.DataGridView3.CurrentCell.Value) _
Select nbdresponse.Elements("offender").Value())
ListBox1.Items.Add(sb)

Next

Would that not achieve what you're trying to do?

Sorry if it's useless :)

TheMightySpud

Guys thanks for your input.

I found another way around this for now but I will test both of these on the next version. I am currently in development/trial mode which is my time to mess up and find the ugliest possible solution!

Here is what I did (for better or worse)

Dim feedXML As XDocument = XDocument.Load("c:\mydata.xml")
        Dim tom = From nbdresponse In feedXML.Descendants("record") _
        Where (nbdresponse.Element("jurisdiction").Value() = Me.DataGridView3.CurrentCell.Value) _
        Select New With { _
                .offender = nbdresponse.Element("offender").Element("fullname").Value(), _
                .dob = nbdresponse.Element("offender").Element("dob").Value(), _
                .ssn = nbdresponse.Element("offender").Element("ssn").Value(), _
                .sex = nbdresponse.Element("offender").Element("sex").Value(), _
                .race = nbdresponse.Element("offender").Element("race").Value(), _
                .haircolor = nbdresponse.Element("offender").Element("haircolor").Value(), _
                .eyecolor = nbdresponse.Element("offender").Element("eyecolor").Value(), _
                .weight = nbdresponse.Element("offender").Element("weight").Value(), _
                .height = nbdresponse.Element("offender").Element("height").Value(), _
                .status = nbdresponse.Element("offender").Element("status").Value(), _
                .address = nbdresponse.Element("offender").Element("address").Value(), _
                .casenumber = nbdresponse.Element("offender").Element("casenumber").Value(), _
                .comments = nbdresponse.Element("offender").Element("comments").Value(), _
                .statelinks = nbdresponse.Element("offender").Element("statelinks").Value(), _
                .imagelinks = nbdresponse.Element("offender").Element("imagelinks").Value() _
                                        }

        If tom.ToList().Count > 0 Then
            TextBox1.Text = "Full Name:  " & tom.ToList()(0).offender & vbCrLf
            TextBox1.Text = TextBox1.Text & "DOB:  " & tom.ToList()(0).dob & vbCrLf
            TextBox1.Text = TextBox1.Text & "SSN:  " & tom.ToList()(0).ssn & vbCrLf
            TextBox1.Text = TextBox1.Text & "Sex:  " & tom.ToList()(0).sex & vbCrLf
            TextBox1.Text = TextBox1.Text & "Race:  " & tom.ToList()(0).race & vbCrLf
            TextBox1.Text = TextBox1.Text & "Hair Color:  " & tom.ToList()(0).haircolor & vbCrLf
            TextBox1.Text = TextBox1.Text & "Eye Color:  " & tom.ToList()(0).eyecolor & vbCrLf
            TextBox1.Text = TextBox1.Text & "Weight:  " & tom.ToList()(0).weight & vbCrLf
            TextBox1.Text = TextBox1.Text & "Height:  " & tom.ToList()(0).height & vbCrLf
            TextBox1.Text = TextBox1.Text & "Status:  " & tom.ToList()(0).status & vbCrLf
            TextBox1.Text = TextBox1.Text & "Address:  " & tom.ToList()(0).address & vbCrLf
            TextBox1.Text = TextBox1.Text & "Case Number:  " & tom.ToList()(0).casenumber & vbCrLf
            TextBox1.Text = TextBox1.Text & "Comments:  " & tom.ToList()(0).comments & vbCrLf
            TextBox1.Text = TextBox1.Text & "State Links:  " & tom.ToList()(0).statelinks & vbCrLf
            TextBox1.Text = TextBox1.Text & "Image Links:  " & tom.ToList()(0).imagelinks & vbCrLf
This question has already been answered. Start a new discussion instead.