1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need help with php code snipet

Discussion in 'Programming' started by Boris_Badenoff, Jan 7, 2015.

  1. #1
    I have a program (attached) that captured the main body of text from a document with the following code:

    $domObj = str_get_html( $document, true );
    $domObj->find( 'br', 2 )->outertext = $domObj->find( 'br', 2 )->outertext . '<div id="wrapper">';
    $domObj->find( 'hr', 0 )->outertext = '</div>' . $domObj->find( 'hr', 0 )->outertext;
    $document = $domObj->save();
    $domObj->clear();


    The main body of text is now enclosed with <div class="entry"> </div>
    I think I have to change the code to something like this but I need help with syntax:
    $domObj = str_get_html( $document, true );
    $domObj->find( 'div class="entry"', 0 )->outertext = $domObj->find( 'div class="entry"', 0 )->outertext . '<div id="wrapper">';
    $domObj->find( '/div', 0 )->outertext = '</div>' . $domObj->find( '/div', 0 )->outertext;
    $document = $domObj->save();
    $domObj->clear();

    I would appreciate any help!
     

    Attached Files:

    Boris_Badenoff, Jan 7, 2015 IP
  2. richie_rich$$$

    richie_rich$$$ Member

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    $domObj = str_get_html( $document, true );
    $domObj->find( 'div.entry', 0 )->outertext = $domObj->find( 'div.entry', 0 )->outertext . '<div class="entry">';
    $domObj->find( '/div', 0 )->outertext = '</div>' . $domObj->find( '/div', 0 )->outertext;
    $document = $domObj->save();
    $domObj->clear();


    Maybe like this ?
     
    richie_rich$$$, Jan 8, 2015 IP
  3. Boris_Badenoff

    Boris_Badenoff Well-Known Member

    Messages:
    381
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Thanks Richie for the suggestion. I gave it a try but it's not finding the <div class="entry"> tag.
     
    Boris_Badenoff, Jan 8, 2015 IP
  4. richie_rich$$$

    richie_rich$$$ Member

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    maybe you can try $domObj->find( 'entry', 0 )
    or some variation of that. ANd just replace everywhere you see div.entry with entry
     
    richie_rich$$$, Jan 8, 2015 IP