Skip to content

xml_find_num: should handle missing node; #356

@discoleo

Description

@discoleo

Example:
xml_find_num(xml, "/some/path/that/does/not/exist")

Should check if it is a request for NUMBER:
if (result_ == NULL) {
// should first check if the request is for NUMBER and return a NA;
SEXP ret = PROTECT(Rf_allocVector(VECSXP, 0));
Rf_setAttrib(ret, R_ClassSymbol, Rf_mkString("xml_missing"));
UNPROTECT(1);
return ret;
}

For missing nodes:

  • either return NA;
  • or add argument to function: xml_find_num(xml, xpath, defaultVal=NA);

Metadata

Metadata

Assignees

No one assigned

    Labels

    reprexneeds a minimal reproducible example

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions