Thread: How to compare the value before split?

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    40

    How to compare the value before split?

    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

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    FYI, know that this is C++/CLI which is not C++. I'm telling you so you know better in the future and may be able to pick a more appropriate forum and/or category. There are a few here who has knowledge of C#/(C++/CLI), but far more who know C++. Picking an appropriate forum and category may help maximize your chances of responses.
    Just so you know.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. split strings (and split thread)
    By mahi in forum C Programming
    Replies: 1
    Last Post: 10-31-2011, 06:56 AM
  2. Replies: 28
    Last Post: 10-23-2011, 07:17 PM
  3. How to compare, without using compare (homework)
    By Mr.777 in forum C++ Programming
    Replies: 8
    Last Post: 03-07-2011, 02:55 AM
  4. compare with chars && compare with int
    By zcrself in forum C Programming
    Replies: 1
    Last Post: 04-22-2010, 03:19 AM