Element-class {xmlr} | R Documentation |
Element, A reference class representing an XML tag
Description
An XML element. Methods allow the user to get and manipulate its child elements and content, directly access the element's textual content, and manipulate its attributes.
Usage
## S4 method for signature 'Element'
as.vector(x)
## S4 method for signature 'Element'
as.character(x)
Arguments
x |
the object to convert |
Methods (by generic)
-
as.vector
: as.vector(Element) -
as.character
: as.character(Element)
Fields
name
The local name of the element
contentList
all the children of this element
attributeList
a list of all the attributes belonging to this element
Methods
addAttributes(attributes)
Add the supplied attributes to the attributeList of this Element
addContent(content)
Appends the child to the end of the content list. return the parent (the calling object)
contentIndex(content)
Find the position of the content in the contentList or -1 if not found
getAttribute(name)
Get an attribute value
getAttributes()
Get the list of attributes
getChild(name)
Return the first child element matching the name
getChildren()
Get all the child Elements belong to this Element
getContent()
Returns the full content of the element as a List that may contain objects of type Text, Element, Comment, ProcessingInstruction, CDATA, and EntityRef
getName()
Return the name of this Element
getText()
Return the text content of this element if any
hasAttributes()
return TRUE if this element has any attributes, otherwise FALSE
hasChildren()
Return TRUE if this element has any child Element nodes
hasContent()
return TRUE if this element has any content, otherwise FALSE
hasText()
Return TRUE if this element has a Text node
removeContent(content)
Remove the specified content from this element
removeContentAt(index)
Remove the content at the given index and return the content that was removed
setAttribute(name, value)
Add or replace an attribute, parameters will be converted to characters
setAttributes(attributes)
Replace the attributes with this named list, NULL or empty list will remove all attributes, all values will be converted to characters
setName(name)
Set the name of this Element
setText(text)
Replace all content with the text supplied