fhir_rm_tag | R Documentation |
Removes a given xml tag from xml objects represented in a fhir_bundle_xml, fhir_bundle_list or character vector.
fhir_rm_tag(x, tag)
## S4 method for signature 'character'
fhir_rm_tag(x, tag)
## S4 method for signature 'fhir_bundle_xml'
fhir_rm_tag(x, tag)
## S4 method for signature 'fhir_bundle_list'
fhir_rm_tag(x, tag)
x |
A fhir_bundle_xml or fhir_bundle_list object or a character vector containing xml objects. |
tag |
A character vector of length 1 containing the tag that should be removed, e.g. |
In the example Hello<div>Please<p>Remove Me</p></div>World!
one could for example remove the
tag p
, resulting in Hello<div>Please</div>World!
or remove the div
tag resulting in
Hello World!
.
An object of the same class as x
where all tags matching the tag
argument are removed.
fhir_rm_div()
#Example 1: Remove tag from xmls in a character vector
string <- c("Hello<div>Please<p>Remove Me</p></div> World!",
"A<div><div><p>B</p></div>C</div>D")
fhir_rm_tag(x = string, tag = "p")
#Example 2: Remove div tags in a single fhir bundle
bundle <- fhir_unserialize(patient_bundles)[[1]]
#example bundle contains html parts in div tags:
cat(toString(bundle))
#remove html parts
bundle_cleaned <- fhir_rm_tag(x = bundle, tag = "div")
#have a look at the result
cat(toString(bundle_cleaned))
#Example 3: Remove div tags in a list of fhir bundles
bundle_list <- fhir_unserialize(patient_bundles)
#remove html parts
bundle_list_cleaned <- fhir_rm_tag(x = bundle_list, tag = "div")
#check out how much the size of the bundle list is reduced by removing html
size_with_html <- sum(sapply(bundle_list, function(x)object.size(toString(x))))
size_without_html <- sum(sapply(bundle_list_cleaned, function(x)object.size(toString(x))))
size_without_html/size_with_html
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.