var parser = new DOMParser(); var htmlDoc = parser.parseFromString(txt, 'text/xml'); // do whatever you want with htmlDoc.getElementsByTagName('a');