I have this XML file (part of) and I need to get version and modify date with jQuery.
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf"
version="3.0"
xml:lang="nl"
unique-identifier="isbn-id"
prefix="cc: http://creativecommons.org/ns# rendition: http://www.idpf.org/vocab/rendition/# ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<meta refines="#title" property="title-type">main</meta>
<meta property="ibooks:version">1.0.440</meta>
<meta property="dcterms:modified">2014-06-08T21:15:17Z</meta>
...
This is the javascript/jQuery function that reads the version and date from above XML file:
$(document).ready(function(){
$.ajax({
type: "GET",
url: "package.opf",
dataType: "xml",
success: function(xml) {
var opf = $.parseXML( xml );
$("span#datum").html($(opf).find("meta[property='dcterms:modified']").text());
$("span#versie").html($(opf).find("meta[property='ibooks:version']").text());
},
error: function(jqHXR, textStatus, errorThrown) {
console.log(jqHXR);
console.log(textStatus);
console.log(errorThrown);}
});
});
which puts version and date in an existing XHTML file, part of which is this:
<p style="margin: 2em;" class="noind">Versie: <span id="versie">1.0.497</span>
<br />Datum: <span id="datum">2014-06-05T22:15:50Z</span>
However: I get blanks. Version and date are overwritten by blanks. How is that possible?
yes it is, I found. But like this:
$(document).ready(function(){
$.get ('package.opf', function(xml) {
$("span#datum").html($(xml).find("meta[property='dcterms\\:modified']").text());
$("span#versie").html($(xml).find("meta[property='ibooks\\:version']").text());
});
});
where the .opf file is in the same directory as the xhtml file that contains the javascript. But I don't think this works for an EPUB3 book in iBooks, because there, I see no change.