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   -   Original Discussion by mojoman
mojoman mojoman is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 12 October 2017, 2:21 PM EDT
Posts: 255
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 11:51 AM
Assigning zero to element of ksh array. robin_simple Emergency UNIX and Linux Support 1 04-02-2012 02:11 AM
Assigning the values to an Array kkraja Shell Programming and Scripting 1 08-11-2008 07:28 AM
perl: Assigning array values.. looza Shell Programming and Scripting 4 07-15-2008 09:08 AM
Assigning values to an array yongho UNIX for Dummies Questions & Answers 4 07-13-2005 09:49 PM



All times are GMT -4. The time now is 06:29 AM.