Hi guys,
I need your help, I have got a problem with my program as they are extract the whole html tags when I am trying to compare between two tags "<p id='mystrings1'> and the <span id="mystrings2">Enabled">". What I want my program to do is to find the tags in the php source called mystrings1 to see if they does exist then find the tags called mystrings2 with value "enabled" on the same line as the mystrings1 for each matches, then extract the mystrings1 value.
On my program, it reads the whole tags like this:
PHP Code:
<p id='mystrings1'>user data 1</p><p id="images"> <a href="images.php?id=1">Images</a></td> | <a href="http://myhotlink.com">Link</a> </td> | <a href="delete.php?id=1">Delete</a> </td> | <span id="mystrings2">Enabled</td>
Here's the form code:
Code:
#include "StdAfx.h"
#include "Form1.h"
using namespace MyProject;
System::Void Form1::timer1_Tick(System::Object^ sender, System::EventArgs^ e)
{
timer1->Enabled = false;
timer1->Stop();
try
{
String ^URL1 = "http://mysite.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=\"mystrings2\">Enabled</td>)";
MatchCollection ^matches1 = Regex::Matches(str1, pattern1);
Match ^m1 = Regex::Match(str1, pattern1);
for each (Match ^x1 in matches1)
{
array<String^> ^StrArr1 = x1->Value->ToString()->Split();
MessageBox::Show(x1->Value->ToString());
}
}
catch (Exception ^ex)
{
}
}
Please can someone tell me how i can compare the tags between mystrings1 and mystrings2 with value "enabled" to see if it have found the matches, then display the messagebox with the mystrings1 value?
Any advice would be much appreciated.
Thanks,
Mark