Description Usage Arguments Details Value Examples
These functions have to be used in cssApply
and
html2df
. They aim to facilitate extraction of
different kind of value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | cssLink(node)
cssClass(node)
cssId(node)
cssSrc(node)
cssValue(node)
cssName(node)
cssNumeric(node, ...)
cssCharacter(node, ...)
|
node |
An xml node |
... |
Parameters passed to |
cssNumeric
extracts the numeric value of an element,
cssCharacter
extracts text. cssLink
extracts the url of a link.
cssSrc
, cssId
, cssClass
, cssName
and
cssValue
are less usefull and extract respectively the source of an
element, its id, its css class, its name and its value (may be usefull for
input elements).
All these function return a chracter string except cssNumeric
which returns a Numeric value
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 | doc <- "<html>
<head></head>
<body>
<div id='character1' class='character'>
<span class='name'>Mike</span>
<span class='level digit'>10</span>
<a href='http://someurl.com'>Complete profile</a>
</div>
<div id='character2' class='character'>
<span class='name'>Stan</span>
<a href='http://someurl2.com'>Complete profile</a>
</div>
</body>
</html>"
doc <- htmlParse(doc)
# Names of the characters
cssApply(doc, ".character>.name", cssCharacter)
# Name of character1
cssApply(doc, "#character1>.name", cssCharacter)
# Urls of the profiles
cssApply(doc, ".character>a", cssLink)
# Level of characters
cssApply(doc, ".character>.level", cssNumeric)
# character 2 does not have level, we would want to have a NA value instead of nothing
cssApplyInNodeSet(doc, ".character", ".level", cssNumeric)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.