Still playing with Chrome Extension and have a little problem when I want to get some information from an XML file. Here is how the XML look :
<?xml version='1.0' encoding='utf8'?>
<objects>
<url>
<domain>...</domain>
<nb_clics>...</nb_clics>
<alias>...</alias>
<title>...</title>
<source>...</source>
<description />
</url>
</objects>
I've tried this but, no result :
<html>
<head>
<style>
body {
width:160px;
}
p {
font-weight:bold;
margin-bottom:0;
}
</style>
</head>
<script type="text/javascript">
function DOMImplementation(sUrl, fCallback) {
var dom;
if(window.ActiveXObject) {
dom = new ActiveXObject("Microsoft.XMLDOM");
dom.onreadystatechange = function() {
if(dom.readyState == 4) {
fCallback(dom);
}
};
}
else if(document.implementation && document.implementation.createDocument) {
dom = document.implementation.createDocument("", "", null);
dom.onload = function() {
fCallback(dom);
}
}
else {
alert("ERROR");
return;
}
dom.load(sUrl);
}
function shrimit() {
var nicknick = localStorage["nick_name"];
var apiapi = localStorage["api_key"];
var yourc = document.getElementById("your");
chrome.tabs.getSelected(null,function(tab) {
var tablink = tab.url;
if(!nicknick || !apiapi){
yourc.setAttribute("value","Set the options");
} else {
DOMImplementation("post.xml", getData);
function getData(oData) {
var tablink2 = oData.getElementsByTagName("alias")[0].firstChild.data;
yourc.setAttribute("value",tablink2);
}
}
});
}
</script>
<body onload="shrimit()">
<input id="your" name="your" type="text" value="" />
</body>
</html>
Can you help me ?