EDN Admin
Well-known member
Hi guys,<br/>
<br/>
Can you please help me with my code as I have a trouble with the returned strings that I have extracted from my php source to add the strings in my listview.<br/>
<br/>
Im reading the tags of mystrings1 and mystrings2 for each paragraph from the php source. I got the returned strings which it looks like this:<br/>
<br/>
<pre class="prettyprint <p id=mystrings1>my strings | http://xfvasfasfasfasf Link </td> | delete.php?id=0 Delete </td> | <span id="mystrings2 Enabled</td>[/code]
<br/>
I want the returned strings to be like this when I reads the tags of mystrings1 and mystrings2 while ignore the other tags.<br/>
<br/>
<pre class="prettyprint <p id=mystrings1>my strings | <span id="mystrings2 Enabled</td>[/code]
<br/>
Heres the code:<br/>
<br/>
<pre>System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)<br/>{<br/> timer1->Enabled = false;<br/> timer1::Stop();<br/><br/> try<br/> {<br/> String ^URL1 = "http://programmingtsite.elementfx.com/myscript.php?user=test&pass=test";<br/> HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));<br/> HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());<br/> StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());<br/> String ^str1 = reader1->ReadToEnd();<br/> String ^pattern1 = "(<p id=mystrings1>(.*?) (.*?)<span id=\"test / (.*?)</td>)";<br/> MatchCollection ^matches1 = Regex::Matches(str1, pattern1);<br/><br/> for each (Match ^x1 in matches1)<br/> {<br/> array<String^> ^StrArr1 = x1->Value->ToString()->Split();<br/> MessageBox::Show(x1->ToString());<br/> ListViewItem ^item1 = gcnew ListViewItem("", 1);<br/>
item1->SubItems->Add(x1->Value->ToString()->Replace("<p
id=mystrings2>", "")->Replace(" ", ""));<br/> listView1::Items->AddRange(gcnew array<ListViewItem^> {item1});<br/> listView1->CheckBoxes = true;<br/><br/> if (x1->Value->Contains("Enabled"))<br/> {<br/> item1->Checked = true;<br/> }<br/> }<br/> }<br/> catch (Exception ^ex)<br/> {<br/> }<br/>}[/code]
<br/>
Do you know how I can ignore the other tags when I get the returned strings of mystrings1 and mystrings2??<br/>
<br/>
Any advice would be much appriecated.
Thanks,<br/>
Mark
View the full article
<br/>
Can you please help me with my code as I have a trouble with the returned strings that I have extracted from my php source to add the strings in my listview.<br/>
<br/>
Im reading the tags of mystrings1 and mystrings2 for each paragraph from the php source. I got the returned strings which it looks like this:<br/>
<br/>
<pre class="prettyprint <p id=mystrings1>my strings | http://xfvasfasfasfasf Link </td> | delete.php?id=0 Delete </td> | <span id="mystrings2 Enabled</td>[/code]
<br/>
I want the returned strings to be like this when I reads the tags of mystrings1 and mystrings2 while ignore the other tags.<br/>
<br/>
<pre class="prettyprint <p id=mystrings1>my strings | <span id="mystrings2 Enabled</td>[/code]
<br/>
Heres the code:<br/>
<br/>
<pre>System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)<br/>{<br/> timer1->Enabled = false;<br/> timer1::Stop();<br/><br/> try<br/> {<br/> String ^URL1 = "http://programmingtsite.elementfx.com/myscript.php?user=test&pass=test";<br/> HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));<br/> HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());<br/> StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());<br/> String ^str1 = reader1->ReadToEnd();<br/> String ^pattern1 = "(<p id=mystrings1>(.*?) (.*?)<span id=\"test / (.*?)</td>)";<br/> MatchCollection ^matches1 = Regex::Matches(str1, pattern1);<br/><br/> for each (Match ^x1 in matches1)<br/> {<br/> array<String^> ^StrArr1 = x1->Value->ToString()->Split();<br/> MessageBox::Show(x1->ToString());<br/> ListViewItem ^item1 = gcnew ListViewItem("", 1);<br/>
item1->SubItems->Add(x1->Value->ToString()->Replace("<p
id=mystrings2>", "")->Replace(" ", ""));<br/> listView1::Items->AddRange(gcnew array<ListViewItem^> {item1});<br/> listView1->CheckBoxes = true;<br/><br/> if (x1->Value->Contains("Enabled"))<br/> {<br/> item1->Checked = true;<br/> }<br/> }<br/> }<br/> catch (Exception ^ex)<br/> {<br/> }<br/>}[/code]
<br/>
Do you know how I can ignore the other tags when I get the returned strings of mystrings1 and mystrings2??<br/>
<br/>
Any advice would be much appriecated.
Thanks,<br/>
Mark
View the full article