Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Assigning DOM Object value to an array

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-17-2017
mojoman mojoman is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 7 August 2017, 1:56 PM EDT
Posts: 254
Thanks: 0
Thanked 1 Time in 1 Post
Assigning DOM Object value to an array

Hi,

I have the following code that makes use of a URL that I store in a variable then create a document object below to work on it.


Code:
    $dom = new DOMDocument;
   @$dom->loadHTML($html);

   $links = $dom->getElementsByTagName('a');

 $links = $dom->getElementsByTagName('a');

 $array = [];

    foreach ($links as $link){
    //Extract and show the "href" attribute.
    $array[]=$link->nodeValue;

} // closing bracket for the foreach

This does not seem to work. I need to assign the nodevalue to an array. How can I go about doing this?
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Assigning * as value in a ksh array ce9888 Shell Programming and Scripting 5 03-02-2015 10:51 AM
Assigning zero to element of ksh array. robin_simple Emergency UNIX and Linux Support 1 04-02-2012 01:11 AM
Assigning the values to an Array kkraja Shell Programming and Scripting 1 08-11-2008 06:28 AM
perl: Assigning array values.. looza Shell Programming and Scripting 4 07-15-2008 08:08 AM
Assigning values to an array yongho UNIX for Dummies Questions & Answers 4 07-13-2005 08:49 PM



All times are GMT -4. The time now is 04:08 PM.