I finally got it to work with this wierd thing:

doc.root.elements["tv_show[@name=\"#{s}\"]/episode[@name=\"#{n}\"]"]

However, you are right, it's not valid haha.