let say i have an html document
<html>
<head>
</head>
<body>
<div>
<p --data-some-att = "My Value">Paragraph with Data> </p>
<a href="someuri" --data-some-link= "true">LINK<a/>
<a href="someuri" >LINK With No data attr<a/>
<p>My Paragrah with out data </p>
</div>
</body>
</html>
i want to find all the elements which have data attributes like the one above(--data-some-att
). so far i can only find all the locations where these attributes are found and here is the code
var vRegex = /\-\-data\-some\-attr\=\"/gi;
var vResult,vIndices = [];
while ( ( vResult = vRegex.exec(htmldocument) ) )
{
vIndices.push(vResult.index);
}
so now i have an array of all the occurrences but how can i get the whole element like the <p>
or <a>
only the one that have a data attribute like (--data-some-att). i am using nodejs and i will highly appreciate any help on getting all other attributes of the element which has a specific attribute set.
thank you!