Created
June 1, 2023 20:13
-
-
Save AlonEirew/a359dfa54f975b604727575555d504d9 to your computer and use it in GitHub Desktop.
Code to automatically parse DBLP research publications into an HTML table with highlighted publisher name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>DBLP Publication</title> | |
</head> | |
<body> | |
<h1>DBLP Publication</h1> | |
<table id="publications"> | |
<thead> | |
<tr> | |
<th>Title</th> | |
<th>Authors</th> | |
<th>Year</th> | |
</tr> | |
</thead> | |
<tbody></tbody> | |
</table> | |
<script> | |
function readXML() { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function () { | |
if (this.readyState == 4 && this.status == 200) { | |
var xmlDoc = this.responseXML; | |
var publications = xmlDoc.getElementsByTagName("article"); | |
var tableBody = document.querySelector("#publications tbody"); | |
for (var i = 0; i < publications.length; i++) { | |
var title = publications[i].getElementsByTagName("title")[0] | |
.childNodes[0].nodeValue; | |
var authors = publications[i].getElementsByTagName("author"); | |
var authorNames = []; | |
for (var j = 0; j < authors.length; j++) { | |
if (authors[j].childNodes[0].nodeValue == "Alon Eirew") { | |
authorNames.push( | |
"<mark>" + authors[j].childNodes[0].nodeValue + "</mark>" | |
); | |
} else { | |
authorNames.push(authors[j].childNodes[0].nodeValue); | |
} | |
} | |
var year = publications[i].getElementsByTagName("year")[0] | |
.childNodes[0].nodeValue; | |
var row = document.createElement("tr"); | |
row.innerHTML = | |
"<td>" + | |
title + | |
"</td><td>" + | |
authorNames.join(", ") + | |
"</td><td>" + | |
year + | |
"</td>"; | |
tableBody.appendChild(row); | |
} | |
} | |
}; | |
xhttp.open("GET", "https://dblp.org/pid/224/0006.xml", true); | |
xhttp.send(); | |
} | |
readXML(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment