I have an XML file having structure like this:
if you are not bound to xmlstarlet try to use xmllint otherwise adjustment of the xpath like shown below could help.
$ xmllint --xpath '//role//sid/../../@name' roles.xml
name="Employees" name="Others"
The xml file for this example looked like
abc
bcd
abc
zxc
In short you can address parent childs attribute by addressing them with ../@*.