Element Sibling

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 2: Line 2:
  
 
This function returns the sibling of an element.
 
This function returns the sibling of an element.
$element sibling gets the element directly next to the one matched.
+
 
 
$element sibling can return #text elements, which can be just whitespace between two tags.
 
$element sibling can return #text elements, which can be just whitespace between two tags.
  
== Example ==
+
To understand what determines an element as the sibling of another element, please see [http://www.w3schools.com/js/js_htmldom_navigation.asp JavaScript HTML DOM Navigation]
  
<pre>
+
The [[The Selectors|Element Selector]] is used to select an item.
navigate("http://ubotstudio.com/resources", "Wait")
+
set(#sales questions, $scrape attribute($element sibling($element sibling(<innertext="Sales Questions">)), "innertext"), "Global")
+
</pre>
+
  
The set command returns the numbers (800) 247-9604 and (303) 242-8116 from the page as the element siblings of the item "Sales Question".
+
'''Element:''' The desired page element.
  
 +
== Example ==
  
[[File:elementsibling.png]]
+
<pre>
 +
load html("<html>
 +
   
 +
  <head>
 +
    <title>DOM Tutorial</title>
 +
  </head>
  
Also for the example:
+
 
 +
  <body>
 +
    <h1>DOM Lesson one</h1>
 +
    <p>Hello world!</p>
 +
  </body>
  
<pre>
+
</html>")
<b>hello</b>    <b>hi</b>
+
set(#sibling, $scrape attribute($element sibling($element sibling(<tagname="h1">)), "innertext"), "Global")
 
</pre>
 
</pre>
  
 
+
The set command returns "Hello World!" by scraping the element sibling of the tag h1, which contains "DOM lesson one".
The element sibling to the first <pre><b></pre> would be a #text element, which just contains "     " which is the blank space between "hello" and "hi"
+

Latest revision as of 19:26, 27 December 2013

$Element Sibling is a Browser Function.

This function returns the sibling of an element.

$element sibling can return #text elements, which can be just whitespace between two tags.

To understand what determines an element as the sibling of another element, please see JavaScript HTML DOM Navigation

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(#sibling, $scrape attribute($element sibling($element sibling(<tagname="h1">)), "innertext"), "Global")

The set command returns "Hello World!" by scraping the element sibling of the tag h1, which contains "DOM lesson one".

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox