Learn R Programming

RXMCDA (version 1.5.5)

getAlternativesIDs: Get IDs of alternatives

Description

Gets the IDs of alternatives, stored in the tag, from an XML tree written according to the XMCDA standard.

Usage

getAlternativesIDs(tree, mcdaConcept = NULL)

Arguments

tree
Object containing the XMCDA XML tree.
mcdaConcept
A string containing the specific mcdaConcept attribute which should be searched for.

Value

The function returns a list structured as follows:
--
The first elements contain vectors with the alternatives' IDs which have been found in each tag. These elements are named according to the mcdaConcept attribute if it can be found.
status
Either OK if all the tags could be correctly read, or the description of the error.

Examples

Run this code
tree = newXMLDoc()

newXMLNode("xmcda:XMCDA", 
           namespace = c("xsi" = "http://www.w3.org/2001/XMLSchema-instance", 
           "xmcda" = "http://www.decision-deck.org/2009/XMCDA-2.0.0"), 
           parent=tree)

root<-getNodeSet(tree, "/xmcda:XMCDA")

alternatives<-newXMLNode("alternatives", attrs=c(mcdaConcept="actions"), 
                         parent=root[[1]], 
                         namespace=c())

alternative<-newXMLNode("alternative",attrs = c(id="x1"), 
                        parent=alternatives, namespace=c())
alternative<-newXMLNode("alternative",attrs = c(id="x2"), 
                        parent=alternatives, namespace=c())
alternative<-newXMLNode("alternative",attrs = c(id="x3"), 
                        parent=alternatives, namespace=c())

y<-getNodeSet(tree,"//alternatives")

x<-getAlternativesIDs(y[[1]])

Run the code above in your browser using DataLab