appendChild: Send DOM requests to a web page

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Send DOM requests to a web page to modify the web page content and/or access existing web page content.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
createElement(pageID, tagName, response=nodePtr(),
              async = FALSE, callback = NULL, tag = getRequestID())
createElementNS(pageID, namespace, tagName, response=nodePtr(),
                async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node,missing'
appendChild(pageID, child, parent, response=htmlNode(),
            ns = FALSE, async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node,DOM_node_ref'
appendChild(pageID, child, parent, response=htmlNode(),
            ns = FALSE, async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref,missing'
removeChild(pageID, child, parent, response=htmlNode(),
            async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref,DOM_node_ref'
removeChild(pageID, child, parent, response=htmlNode(),
            async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node,DOM_node_ref,missing'
replaceChild(pageID, newChild, oldChild, parent, response=htmlNode(),
            ns = FALSE, async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node,DOM_node_ref,DOM_node_ref'
replaceChild(pageID, newChild, oldChild, parent, response=htmlNode(),
            ns = FALSE, async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref,character'
getAttribute(pageID, elt,
attrName, response = NULL,
             async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref,character,character'
setAttribute(pageID, elt, attrName, attrValue,
             async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,character'
getElementById(pageID, id, response=htmlNode(),
               async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,character'
getElementsByTagName(pageID, name, response=htmlNode(),
                     async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,character,missing'
getElementsByClassName(pageID, name, root, response=htmlNode(),
                       async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,character,DOM_node_ref'
getElementsByClassName(pageID, name, root, response=htmlNode(),
                       async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref'
click(pageID, elt, callback = NULL, tag
= getRequestID())
## S4 method for signature 'numeric,DOM_obj_ref,character'
getProperty(pageID, object,
propName, response = NULL,
                       async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_obj_ref,character,DOM_obj_ref'
setProperty(pageID, object,
propName, value, warn = TRUE,
                       async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_obj_ref,character,DOM_value'
setProperty(pageID, object,
propName, value, warn = TRUE,
                       async = FALSE, callback = NULL, tag = getRequestID())
styleSheets(pageID, async=FALSE, callback=NULL, tag=getRequestID())
## S4 method for signature 'numeric,DOM_CSSStyleSheet_ptr,character,numeric'
insertRule(pageID, styleSheet, rule, index,
                       async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_CSSStyleSheet_ptr,numeric'
deleteRule(pageID, styleSheet, index,
                       async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_CSSStyleDeclaration_ptr,character'
removeProperty(pageID, style, propName, response = NULL,
                       async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_CSSStyleDeclaration_ptr'
propertyNames(pageID, style,
                       async = FALSE, callback = NULL, tag = getRequestID())

Arguments

pageID

A page identifier, as returned by, e.g., htmlPage.

tagName

A character value describing an HTML (or SVG) tag name.

namespace

A character value describing a valid namespace (e.g., "http://www.w3.org/1999/xml" or "http://www.w3.org/2000/svg")

child

A DOM node representation, e.g., the result from htmlNode() (for a new node), or css() (for an existing node).

parent

A DOM node representation for an existing node (e.g., the result from css()).

newChild

A DOM node representation, e.g., the result from htmlNode() (for a new node), or css() (for an existing node).

oldChild

A DOM node representation for an existing node (e.g., the result from css()).

elt

A DOM node representation for an existing node (e.g., the result from css()).

object

A DOM object representation for an existing node (e.g., the result from objPtr()).

propName

A character value specifying a DOM object property name.

value

A DOM object representation for an existing node (or a simple numeric, character, or logical value.

response

A DOM node representation that provides a template for the return value, e.g., htmlNode() to return HTML or css() to return CSS.

id

A character value specifying an element id attribute.

name

A character value specifying a tag name (or ‘*’) or a class name (or several class names separated by spaces).

root

A DOM node representation for an existing node (e.g., the result from css()).

attrName

The attribute name.

attrValue

The attribute value (will be coerced to a character value).

styleSheet

A DOM node representation for an existing style sheet.

style

A DOM node representation for an existing style declaration.

rule

A character value describing a CSS rule.

index

A numeric index describing the location of the rule within the stylesheet.

ns

A namespace for the child element that is to be created. Valid values are "HTML" or "SVG" (or NULL).

warn

A logical indicating whether to emit warning messages if we try to set a read-only property.

async

A logical indicating whether the request is asynchronous.

callback

A function to be called when the DOM request has been fulfilled.

tag

A unique request identifier.

Details

These functions implement (some of) the basic DOM interface to web page content.

For adding SVG content within HTML, you should specify ns="SVG" and for adding HTML content within SVG, you should specify ns="HTML".

If async is FALSE, the request is synchronous and R blocks until the browser has sent a response. Otherwise, the request is asynchronous and control is returned to the command line.

If callback is non-NULL, it will be run when the browser responds. The callback function will be called with a single argument, which will contain the response from the web browser (see the Value section below). The callback can contain further requests, but they must be asynchronous requests.

A click is always asynchronous (the request may be fulfilled in R before the browser has completed handling the click event); this function is aimed at debugging with a headless browser.

Value

Most functions return a DOM node, which could be, e.g., HTML or CSS, depending on the response argument.

For createElement, the default is to return a DOM_note_ptr object (because the element created is not part of the document, so cannot be identified from R any other way).

For appendChild, the child element that was added.

For removeChild, the child element that was removed.

For replaceChild, the old child element that was replaced.

For getElementById, getElementsByTagName, and getElementsByClassName, the matching elements.

Both setAttribute and click return NULL.

Author(s)

Paul Murrell

References

https://www.w3.org/DOM/

See Also

htmlPage, htmlNode

Examples

1
2
3
headlessPage <- htmlPage(client=phantomClient)
appendChild(headlessPage, htmlNode("<p>test</p>"))
closePage(headlessPage)

pmur002/DOM documentation built on May 25, 2019, 10:20 a.m.