Note that there are some explanatory texts on larger screens.

plurals
  1. POProperly parsing strings line by line from a website
    primarykey
    data
    text
    <p>I have this being echo into a blank page:</p> <pre><code>echo "Testing|Testing1|Testing2|Testing3|Testing4&lt;br/&gt;"; echo "Something|Something1|Something2|Something3|Something4"; </code></pre> <p>Now I have a listview. In this example it would create 2 rows with 5 columns. So my question is, how to read line by line to properly create the number of rows that are displayed on the website?</p> <p>Here's my code so far:</p> <pre><code>WebClient client = new WebClient(); string downloadString = client.DownloadString("https://example.com/Testing.php"); string[] downloadString2 = downloadString.Split( new char[] { (char)'|' }, System.StringSplitOptions.RemoveEmptyEntries); ListViewItem item = new ListViewItem( new[] { downloadString2[0].ToString(), downloadString2[1].ToString(), downloadString2[2].ToString(), downloadString2[3].ToString(), downloadString2[4].ToString() }); listView1.Items.Add(item); </code></pre> <p>(The columns are already created in the listview)</p> <p>-- Edit: This worked fine for me:</p> <pre><code> WebClient client = new WebClient(); string downloadString = client.DownloadString("https://example.com/Testing.php"); string[] stringSeparators = new string[] { "&lt;br/&gt;" }; string[] Lines = downloadString.Split(stringSeparators, StringSplitOptions.None); string[] things = new string[5]; // Fixed size. I might find a way later to make it dynamically int i = 0; foreach (string line in Lines) { string[] words = line.Split('|'); i = 0; foreach (string word in words) { things[i] = word; i++; } ListViewItem item = new ListViewItem( new[] { things[0], things[1], things[2], things[3], things[4] }); listView1.Items.Add(item); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload