The issue you're encountering is likely because the Yahoo Finance page content is loaded dynamically with JavaScript, and rvest (which is based on static HTML parsing) can’t access the content that's rendered client-side.
3 Key Fixes:
node_txt is not being passed correctly
You wrote contains(@class, node_txt) this passes the literal string "node_txt" instead of the value. You need to interpolate the variable.
Yahoo content loads dynamically
Most fields like "Open", "Previous Close", etc., are rendered after JavaScript runs, so rvest won’t see them unless they’re in the static HTML.
Better: Parse data from the page's embedded JSON
Yahoo Finance embeds the full quote data in a JavaScript object you can parse it instead of scraping DOM nodes.