Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Get text from html

Discussion in 'Scripting' started by Bruno Gysin, Sep 8, 2014.

  1. Bruno Gysin

    Bruno Gysin

    Joined:
    May 2, 2011
    Posts:
    23
    I can not get a text from a html
    My Html:
    Code (Html):
    1. <html>
    2.     <head>
    3.         <title>Page Teste</title>
    4.     </head>
    5.     <body>
    6.         <input type="hidden" name="confirm" value="SimpleConfirmValue"/>
    7.     </body>
    8. <html>


    in php i use
    Code (php):
    1.  
    2.         $Confrim0 = @explode('<input type="hidden" name="confirm" value="', $PegarConteudo);
    3.         $Confrim1 = @explode('"/>',$PrimeiraPart[1]);
    4.         $ConfrimI = $Confrim1[0];
    5.  
    ConfrimI Return = SimpleConfirmValue

    And Web JavaScript :
    Code (JavaScript):
    1.  
    2.         var Confrim0 = HTML.split('<input type="hidden" name="confirm" value="');
    3.         var Confrim1= Confrim0[1].split('"/>');
    4.         var ConfrimI = Confrim1[0];
    5.  
    ConfrimI Return: SimpleConfirmValue




    in Unity3D I try to do this the same way but does not work

    Code (JavaScript):
    1.     var ConfrimP0 : String[];
    2.     var ConfrimP1 : String[];
    3.     var ConfrimI : String;
    4.  
    5.     ConfrimP0 = HTML.Split('<input type="hidden" name="confirm" value="'[0]);
    6.     ConfrimP1= ConfrimP0[1].Split('"/>'[0]);
    7.     ConfrimI = ConfrimP1[0];
    ConfrimI Return : html>


    why does this happen?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    In your Split functions, you're using the char version of the function. Your first split is splitting it by '<', and your second, with a quotation mark.

    Try the string variant of the function instead?
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    Sidenote: Your HTML is malformed. Last tag should be </html>
     
  4. Bruno Gysin

    Bruno Gysin

    Joined:
    May 2, 2011
    Posts:
    23
    string variant ?
    I do not quite understand




    I did now only for testing