how to split the strings?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi guys,<br/>
<br/>
I am working on my program to read the html tags using with httprequest. When i set the timer, it connect to my site via httprequest and it will read the whole tags from the php source when I am trying to compare between <p id=mystrings1> and the <span
id="mystrings2 Enabled .
heres what the messagebox display:<br/>
PHP:
 <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><br/>
<br/>
<br/>
Heres the form code:<br/>
<br/>
Code:
 #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/>
}
<br/>
<br/>
What I am trying to do is to find the tags called mystrings1 and mystrings2 with the value "enabled". I want to see if it have find the matches in the same line as the mystrings1 and mystrings2, then ignore the other tags and display the messagebox just like
this:
Code:
<p id=mystrings1>user data 1 <span id="mystrings2 Enabled</td>
what my program are doing is they are looking to compare the two tags between mystrings1 and mystrings2, then it display the whole tags from the php source.
<br/>
Please can someone tell me how i can split the whole tags when i am trying to compare with the two tags?<br/>
<br/>
Thanks, <br/>
Mark

View the full article
 
Back
Top