sed
You could simplify it a bit with this version:
$ echo '<e1 name="file1" id="id1" anotherId="id2">' | \
sed 's/.*name="\(.*\)" id.*/\1/'
You don't need to wrap everything with parens, only the things you're interested in saving for use later on, so you can remove.
grep
You can also use grep's ability to use Perl's regular expression engine (PCRE):
$ echo '<e1 name="file1" id="id1" anotherId="id2">' | \
grep -Po '(?<=name=")(\w+)(?=")'
This use's PCRE's ability to look ahead and lookbehind. The notation looks for a sequence of characters such as "name=" before what we're looking for. This bit is doing this:
(?<=name=")
It then looks for a series of word characters, this is what we're actually looking for:
(\w+)
The last bit that's doing the lookahead is this:
(?=")
It's looking for a quotation mark (") after what we're looking for.
awk
$ echo '<e1 name="file1" id="id1" anotherId="id2">' | \
awk '{gsub("\"","");split($2,a,"="); print a[2]}'
This variant strings the double quotes (`"``) doing a global substitution:
gsub("\"","")
The remaining string would be this:
<e1 name=file1 id=id1 anotherId=id2>
So we can let awk split this as it normally would and the 2nd column would be the bit we're interested in getting. That would be $2 to awk. So we could take that variable and then split it on equal signs (=).
split($2,a,"=");
This will split $2, and store the results in an array, a. Afterwords we can print the 2nd element in the array, this being everything on the right side of the equal sign from $2.
file1