Element Child

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Example)
 
(6 intermediate revisions by one user not shown)
Line 1: Line 1:
 
$Element Child is a [[Browser Functions|Browser Function]].
 
$Element Child is a [[Browser Functions|Browser Function]].
  
This function returns the child of a selected element.
+
This function returns the child of a selected element. To understand what determines an element as the child of another element, please see [http://www.w3schools.com/js/js_htmldom_navigation.asp JavaScript HTML DOM Navigation]
 +
 
 +
$element child gets the child html element of the one matched with the selector.
 +
 
 +
The [[The Selectors|Element Selector]] is used to select an item.
 +
 
 +
'''Element:''' The desired page element.
  
  
Line 7: Line 13:
  
 
<pre>
 
<pre>
navigate("http://ubotstudio.com/resources", "Wait")
+
load html("<html>
set(#logo, $scrape attribute($element child(<href="http://www.ubotstudio.com/index2">), "src"), "Global")
+
   
set(#sales questions, $scrape attribute($element sibling($element sibling(<innertext="Sales Questions">)), "innertext"), "Global")
+
  <head>
</pre>
+
    <title>DOM Tutorial</title>
 +
  </head>
  
$element child gets the child html element of the one matched with the selector
+
 
$element sibling gets the element directly next to the one matched
+
  <body>
$element sibling can return #text elements, which can be just whitespace between two tags
+
    <h1>DOM Lesson one</h1>
For the example
+
    <p>Hello world!</p>
 +
  </body>
 +
 
 +
</html>")
 +
set(#child, $scrape attribute($element child($element offset(<tagname="html">, 0)), "innertext"), "Global")
  
<pre>
 
<b>hello</b>    <b>hi</b>
 
 
</pre>
 
</pre>
  
The element sibling to the first <b> would be a #text element
+
 
which just contains "     " which is the blank space between "hello" and "hi"
+
The set command returns: "DOM Tutorial", which is the child of the selected tag HTML.

Latest revision as of 16:19, 24 December 2013

$Element Child is a Browser Function.

This function returns the child of a selected element. To understand what determines an element as the child of another element, please see JavaScript HTML DOM Navigation

$element child gets the child html element of the one matched with the selector.

The Element Selector is used to select an item.

Element: The desired page element.


[edit] Example

load html("<html>
    
  <head>
    <title>DOM Tutorial</title>
  </head>

  
  <body>
    <h1>DOM Lesson one</h1>
    <p>Hello world!</p>
  </body>

</html>")
set(#child, $scrape attribute($element child($element offset(<tagname="html">, 0)), "innertext"), "Global")


The set command returns: "DOM Tutorial", which is the child of the selected tag HTML.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox