Split the returned strings
Hi guys,
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.
I'm reading the tags of mystrings1 and mystrings2 for each paragraph from the php source. I got the returned strings which it looks like this:
PHP Code:
<p id='mystrings1'>my strings</p> | <a href="http://xfvasfasfasfasf">Link</a> </td> | <a href="delete.php?id=0">Delete</a> </td> | <span id="mystrings2">Enabled</td>
I want the returned strings to be like this when I reads the tags of mystrings1 and mystrings2 while ignore the other tags.
PHP Code:
<p id='mystrings1'>my strings</p> | <span id="mystrings2">Enabled</td>
Here's the code:
Code:
System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
timer1->Enabled = false;
timer1::Stop();
try
{
String ^URL1 = "http://programmingtsite.elementfx.com/myscript.php?user=test&pass=test";
HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));
HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());
StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());
String ^str1 = reader1->ReadToEnd();
String ^pattern1 = "(<p id='mystrings1'>(.*?)</p>(.*?)<span id=\\"test / ">(.*?)</td>)";
MatchCollection ^matches1 = Regex::Matches(str1, pattern1);
for each (Match ^x1 in matches1)
{
array<String^> ^StrArr1 = x1->Value->ToString()->Split();
MessageBox::Show(x1->ToString());
ListViewItem ^item1 = gcnew ListViewItem("", 1);
item1->SubItems->Add(x1->Value->ToString()->Replace("<p
id='mystrings2'>", "")->Replace("</p>", ""));
listView1::Items->AddRange(gcnew array<ListViewItem^> {item1});
listView1->CheckBoxes = true;
if (x1->Value->Contains("Enabled"))
{
item1->Checked = true;
}
}
}
catch (Exception ^ex)
{
}
}
Do you know how I can ignore the other tags when I get the returned strings of mystrings1 and mystrings2??
Any advice would be much appriecated.
Thanks,
Mark