Hi all!
I have a problem that I've been struggling with for quite sometime. In short I've successfully parsed a xml file from a string. But I can't seem to access the correct elements. The thing is I'm reading the xml file data via javascript but in the xml file the nodes use namespaces. To get an element that doesn't have a namespace can I easily access.
In the xml file:
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="pub-id" prefix="cc: http://creativecommons.org/ns#">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Moby-Dick</dc:title>
<meta refines="#title" property="title-type">main</meta>
<dc:creator id="creator">Herman Melville</dc:creator>
<meta refines="#creator" property="file-as">MELVILLE, HERMAN</meta>
<meta refines="#creator" property="role" scheme="marc:relators">aut</meta>
<dc:identifier id="pub-id">code.google.com.epub-samples.moby-dick-basic</dc:identifier>
<dc:language>en-US</dc:language>
<meta property="dcterms:modified">2012-01-18T12:47:00Z</meta>
<dc:publisher>Harper & Brothers, Publishers</dc:publisher>
<dc:contributor id="contrib1">Dave Cramer</dc:contributor>
<meta refines="#contrib1" property="role" scheme="marc:relators">mrk</meta>
<dc:rights>This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.</dc:rights>
<link rel="cc:license" href="http://creativecommons.org/licenses/by-sa/3.0/"/>
<meta property="cc:attributionURL">http://code.google.com/p/epub-samples/</meta>
</metadata>
My javascript:
xmlDoc = parseXML(XMLString);
var a = xmlDoc.getElementById("creator");
var author = a.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/","creator");
No this is what I've tried and it doens't seem to work. I did search for other options but couldn't find something that helped! If anyone could please help!