I have a list in a variable named api_result
which returns the following output in the console when calling it:
> api_result
{xml_nodeset (200)}
[1] <visitor_activity>\n <id>136212161</id>\n <prospect_id>2680070</prospect_id>\n <type>6</type>\n <type_name>Email</type_name>\n <det ...
[2] <visitor_activity>\n <id>136212163</id>\n <prospect_id>21304456</prospect_id>\n <type>6</type>\n <type_name>Email</type_name>\n <de ...
etc...
I want to append to api_result
a second list named api_result2
which has the same length and structure.
When using the c()
function, the output in the console seems to have changed when calling api_result
:
> api_result <- c(api_result,api_result2)
> api_result
[[1]]
{xml_node}
<visitor_activity>
[1] <id>136212161</id>
[2] <prospect_id>2680070</prospect_id>
[3] <type>6</type>
[4] <type_name>Email</type_name>
The problem I'm having with this is that the following code was working fine on the api_result
:
prospect_ids <- xml_text(xml_find_all(api_result, "//prospect_id"))
But now it's failing, and returns the following error:
Error in UseMethod("xml_find_all") :
no applicable method for 'xml_find_all' applied to an object of class "list"
How can I ensure that the structure of the list is maintained, so that my xml_find_all()
function keeps working?