Select attribute value within attribute with multiple values

Vanessa Juloux <[email protected]> Thu, 6 Apr 2017 00:43:28 +0200
Newsgroups gmane.text.tei.general
Message-ID <[email protected]>
Dear all,

I am currently parsing TEI data within R, amongst which @ana attributes in a <ref> that have several values.
My apologies for this post in the TEI list, but since parsing TEI data is very specific, I hope you will be able to help me since I am looking for an answer for few days now. 

Do you know how is working the hierarchy of multiple attribute values?

Example in TEI: <ref ana="whatAction #ktu1-3_ii_l6b_tḫtṣb #confrontation #action">Action, subcategory confrontation
                                        <stage ana="whatResult #result #defeate_ofOpposition"/></ref>

The parsing in R is done with getNodeSet and xmlGetAttr functions:

interpRef <- getNodeSet(doc,"//ns:ref[contains(@ana, 'whatAction')]", ns) 
#interpRef=paste0("'#",interpRef,"'")
interpRef_ana <- for (i in 1:length(interpRef)) print(paste(xmlGetAttr(interpRef[[i]],"ana")))

Result:
[1] "whatAction #ktu1-3_ii_l6b_tḫtṣb #confrontation #action"
Do you know how I can select relevant attribute value from @ana? I would like to have only:
[1] "#ktu1-3_ii_l6b_tḫtṣb #confrontation"


A suggestion?

In advance, thank you very much.

Best,
Vanessa