I suppose a more straight forward answer would be, yes, it will work. However, it's obviously a more careful process than doing a straight forward restore.
Namely, because if you do it wrong, it may end up wiping out your entire database anyway.
For example, a lot of MySQL dumps will often do a "USE database; DROP table;" before inserting the new data. That, of course, would delete the table before trying to add the data back from the dump.
So, in other words, be careful... And definitely take a backup beforehand, and be prepared to fully restore back to that backup in the event anything goes wrong.
Finally, there is probably more to it than you might imagine. As well as the nodes in the xf_node table, there is also the forums in the xf_forum table. There's the threads in the xf_thread table, and then there's the posts in the xf_post table. If all that has been deleted, unfortunately all of the attachments attached to posts in those forums will be deleted too. So that's the xf_attachment and xf_attachment_data table (and all the files which were on the file system for those attachments have probably been cleaned up by now). There's also all of the liked content, but that's probably of somewhat lesser importance.
There of course may be other tables and cached data which are lost, too, which may require rebuilds.
So, that's where the theoretically comes in.
All in all, it may be safer to just go back to the last back up completely, but it of course means losing anything since.
Either way it's not a decision to be made lightly...