Assigning DOM Object value to an array


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Assigning DOM Object value to an array
# 1  
Old 07-17-2017
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assigning * as value in a ksh array

I want to extract each and single character from a password string and put it in an array. I tried this : set -A password "echo $passwd | awk '{for (i=1; i<=length($1); i++) printf "%s ",substr($1,i,1)}'` It's working as long that the password string doesn't contains any * I tried a few... (5 Replies)
Discussion started by: ce9888
5 Replies

2. Shell Programming and Scripting

Need help on Assigning a Array variable from Background Functions

I have a question on how can I assign a output of a function to a variable which is executed in background. Here is my example $ cat sample_program.sh #!/bin/ksh exec_func () { sleep 1 v=`expr $1 + 100` print $v } export OUT_ARR date for i in 1 2 do OUT_ARR=`exec_func $i` &... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

3. Shell Programming and Scripting

Assigning Column Values to ARRAY in ksh

Hi , i have file which is having two fields in it (#delimited) ABC#FILE_01.DAT DEF#FILE_02.DAT i want to write first field values to one array example A_01 and second field values to B_02 array please let me know how to do this ,my final requirement i have send out a mail for each record... (2 Replies)
Discussion started by: kkabc789
2 Replies

4. Shell Programming and Scripting

Reading from a file and assigning to an array in perl

I wrote a simply perl that searched a file for a particualr value and if it found it, rite it and the next three lines to a file. Now I have been asked to check those next three lines for a different value and only write those lines if it finds the second value. I was thinking the best way to... (1 Reply)
Discussion started by: billprice13
1 Replies

5. Emergency UNIX and Linux Support

Assigning zero to element of ksh array.

set -A matched #find referenced files. for i in ${file_names_html} do counter_j=0 for j in ${file_names_minus_index} do match=`cat $i | grep... (1 Reply)
Discussion started by: robin_simple
1 Replies

6. Shell Programming and Scripting

Assigning values for a dynamic array for an input

Hello, Can somebody please give me a snippet for the below requirement. I want to assign the values separeted by a comma to be assigned to a dynamic array. If I give an input (read statement) like abc1,abc2,abc3,abc4,abc5, all these strings abc* should be assigned to an array like below... (2 Replies)
Discussion started by: suneelj
2 Replies

7. Shell Programming and Scripting

Assigning values to an array via for/while loop

I need to do something like this: for i in 1 2 3 4 5; do arr=$(awk 'NR="$i" { print $2 }' file_with_5_records) done That is, parse a file and assign values to an array in an ascending order relative to the number of record in the file that is being processed on each loop. Is my... (2 Replies)
Discussion started by: fiori_musicali
2 Replies

8. Shell Programming and Scripting

Assigning the values to an Array

hi every body, i donot know how to assign a array varible with a file see i having file more file property1 Name property2 Address the above two line are tab Space seperated between the property and its value i want to seperate it and assign to... (1 Reply)
Discussion started by: kkraja
1 Replies

9. Shell Programming and Scripting

perl: Assigning array values..

I have to add a variable value to an array, something like this: ...... @my_array_name = $value_of_this_variable; This doesnt seem to work, any ideas why? Thanks! (4 Replies)
Discussion started by: looza
4 Replies

10. UNIX for Dummies Questions & Answers

Assigning values to an array

The way I've been using arrays currently have been: #!/bin/ksh set -A myArray myArray=value1 myArray=value2 myArray=value3 myArray=value4 Is there a way I can assign values to an array that will automatically place the value into the next element in the array like: myArray=value1... (4 Replies)
Discussion started by: yongho
4 Replies
Login or Register to Ask a Question
CSS::DOM::Style(3pm)					User Contributed Perl Documentation				      CSS::DOM::Style(3pm)

NAME
CSS::DOM::Style - CSS style declaration class for CSS::DOM VERSION
Version 0.14 SYNOPSIS
use CSS::DOM::Style; $style = CSS::DOM::Style::parse(' text-decoration: none '); $style->cssText; # returns 'text-decoration: none' $style->cssText('color: blue'); # replace contents $style->getPropertyValue('color'); # 'blue' $style->color; # same $style->setProperty(color=>'green'); # change it $style->color('green'); # same DESCRIPTION
This module provides the CSS style declaration class for CSS::DOM. (A style declaration is what comes between the braces in "p { margin: 0 }".) It implements the CSSStyleDeclaration DOM interface. CONSTRUCTORS
CSS::DOM::Style::parse( $string ) CSS::DOM::Style::parse( $string, property_parser => $parser ) This parses the $string and returns a new style declaration object. This is useful if you have text from an HTML "style" attribute, for instance. For details on $property_parser, see CSS::DOM::PropertyParser. new CSS::DOM::Style $owner_rule new CSS::DOM::Style owner => $owner_rule, property_parser => $p You don't normally need to call this, but, in case you do, here it is. $owner_rule, which is optional, is expected to be a CSS::DOM::Rule object, or a subclass like CSS::DOM::Rule::Style. METHODS
cssText ( $new_value ) Returns the body of this style declaration (without the braces). If you pass an argument, it will parsed and replace the existing CSS data. getPropertyValue ( $name ) Returns the value of the named CSS property as a string. getPropertyCSSValue ( $name ) Returns an object representing the property's value. (See CSS::DOM::Value.) removeProperty ( $name ) Removes the named property, returning its value. getPropertyPriority Returns the property's priority. This is usually the empty string or the word 'important'. setProperty ( $name, $value, $priority ) Sets the CSS property named $name, giving it a value of $value and setting the priority to $priority. length Returns the number of properties item ( $index ) Returns the name of the property at the given index. parentRule Returns the rule to which this declaration belongs. modification_handler ( $coderef ) This method, not part of the DOM, allows you to attach a call-back routine that is run whenever a change occurs to the style object (with the style object as its only argument). If you call it without an argument it returns the current handler. With an argument, it returns the old value after setting it. property_parser This returns the parser that was passed to the constructor. This module also has methods for accessing each CSS property directly. Simply capitalise each letter in a CSS property name that follows a hyphen, then remove the hyphens, and you'll have the method name. E.g., call the "borderBottomWidth" method to get/set the border-bottom- width property. One exception to this is that "cssFloat" is the method used to access the 'float' property. (But you can also use the "float" method, though it's not part of the DOM standard.) SEE ALSO
CSS::DOM CSS::DOM::Rule::Style CSS::DOM::PropertyParser HTML::DOM::Element perl v5.10.1 2010-12-10 CSS::DOM::Style(3pm)