EDN Admin
Well-known member
Hi guys,<br/>
<br/>
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.<br/>
<br/>
On my program, it reads the whole tags like this:<br/>
<br/>
Heres the form code:<br/>
<pre class="prettyprint <p id=mystrings1>user data 1 <p id="images images.php?id=1 Images </td> | http://myhotlink.com Link </td> | delete.php?id=1 Delete </td> | <span id="mystrings2 Enabled</td>[/code]
<br/>
<br/>
Heres the form code:<br/>
<pre class="prettyprint #include "StdAfx.h"<br/>#include "Form1.h"<br/><br/><br/>using namespace MyProject;<br/><br/>System::Void Form1::timer1_Tick(System::Object^ sender, System::EventArgs^ e)<br/>{<br/> timer1->Enabled = false;<br/> timer1->Stop();<br/><br/> try<br/> {<br/> String ^URL1 = "http://mysite.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="mystrings2 Enabled</td>)";<br/> MatchCollection ^matches1 = Regex::Matches(str1, pattern1);<br/> Match ^m1 = Regex::Match(str1, pattern1);<br/><br/> for each (Match ^x1 in matches1)<br/> {<br/> array<String^> ^StrArr1 = x1->Value->ToString()->Split();<br/> MessageBox::Show(x1->Value->ToString());<br/> }<br/> }<br/> catch (Exception ^ex)<br/> {<br/> }<br/>}[/code]
<br/>
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?<br/>
<br/>
Any advice would be much appreciated.<br/>
<br/>
Thanks,<br/>
Mark<br/>
View the full article
<br/>
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.<br/>
<br/>
On my program, it reads the whole tags like this:<br/>
<br/>
Heres the form code:<br/>
<pre class="prettyprint <p id=mystrings1>user data 1 <p id="images images.php?id=1 Images </td> | http://myhotlink.com Link </td> | delete.php?id=1 Delete </td> | <span id="mystrings2 Enabled</td>[/code]
<br/>
<br/>
Heres the form code:<br/>
<pre class="prettyprint #include "StdAfx.h"<br/>#include "Form1.h"<br/><br/><br/>using namespace MyProject;<br/><br/>System::Void Form1::timer1_Tick(System::Object^ sender, System::EventArgs^ e)<br/>{<br/> timer1->Enabled = false;<br/> timer1->Stop();<br/><br/> try<br/> {<br/> String ^URL1 = "http://mysite.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="mystrings2 Enabled</td>)";<br/> MatchCollection ^matches1 = Regex::Matches(str1, pattern1);<br/> Match ^m1 = Regex::Match(str1, pattern1);<br/><br/> for each (Match ^x1 in matches1)<br/> {<br/> array<String^> ^StrArr1 = x1->Value->ToString()->Split();<br/> MessageBox::Show(x1->Value->ToString());<br/> }<br/> }<br/> catch (Exception ^ex)<br/> {<br/> }<br/>}[/code]
<br/>
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?<br/>
<br/>
Any advice would be much appreciated.<br/>
<br/>
Thanks,<br/>
Mark<br/>
View the full article