JSFiddle - React, Tailwind, and code Playground
by brianjmiller
JavaScript
YUI().use("node", function(Y) {
var data = '<html xmlns="http://www.w3.org/1999/xhtml"><head>' + '<title>This is title</title> <meta name="description" content="This is description" /> </head><body></body></html>';
var title = (/<title>(.*?)<\/title>/m).exec(data)[1];
console.log(title); //output: This is title
var metaList = Y.Node.create(data).all("meta");
metaList.each(function(node) {
var c = node.get('content'),
n = node.get('name');
if (n !== null) {
if (n.toLowerCase() === 'description') {
desc = c;
}
}
});
console.log(desc); // output : This is description
});