xml - xmlstarlet selecting a node with a specific attribute value -
i new of please forgive me if answer totally obvious! have xml document downloaded ncbi , trying extract host information each entry, looks little (but more nested):
<orgname_mod> <orgmod> <orgmod_subtype value="strain">2</orgmod_subtype> <orgmod_subname>mvs/jiroft.irn/14.15/1[b3]</orgmod_subname> </orgmod> <orgmod> <orgmod_subtype value="nat-host">21</orgmod_subtype> <orgmod_subname>homo sapiens</orgmod_subname> </orgmod> </orgname_mod>
i've had success using following:
xml sel -t -v //orgname_mod/orgmod[2]/orgmod_subname -n file.xml
but problem there more or less information in orgmod nodes , host isn't in second position. i've tried every version of try , select host node specifically:
xml sel -t -m //orgmod/orgmod_subtype[@value=nat-host] -v ../orgmod_subname -n file.xml
i want select orgmod_subtype node nat-host attribute , subsequently print sibling (?) orgmod_subname node species name.
any appreciated!
try way:
//orgmod[orgmod_subtype/@value = 'nat-host']/orgmod_subname/text()
Comments
Post a Comment