diff --git a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js index f01156541..3a4a2e96b 100644 --- a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js +++ b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js @@ -35,10 +35,10 @@ exports["application/enex+xml"] = function(text,fields) { var noteNodes = doc.querySelectorAll("note"); $tw.utils.each(noteNodes,function(noteNode) { var result = { - title: noteNode.querySelector("title").textContent, + title: getTextContent(noteNode,"title"), type: "text/html", tags: [], - text: noteNode.querySelector("content").textContent + text: getTextContent(noteNode,"content") }; $tw.utils.each(noteNode.querySelectorAll("tag"),function(tagNode) { result.tags.push(tagNode.textContent); @@ -49,11 +49,11 @@ exports["application/enex+xml"] = function(text,fields) { results.push(result); $tw.utils.each(noteNode.querySelectorAll("resources"),function(resourceNode) { results.push({ - title: resourceNode.querySelector("resource-attributes>file-name").textContent, - type: resourceNode.querySelector("mime").textContent, - width: resourceNode.querySelector("width").textContent, - height: resourceNode.querySelector("height").textContent, - text: resourceNode.querySelector("data").textContent + title: getTextContent(resourceNode,"resource-attributes>file-name"), + type: getTextContent(resourceNode,"mime"), + width: getTextContent(resourceNode,"width"), + height: getTextContent(resourceNode,"height"), + text: getTextContent(resourceNode,"data") }); }); }); @@ -61,4 +61,8 @@ exports["application/enex+xml"] = function(text,fields) { return results; }; +function getTextContent(node,selector) { + return (node.querySelector(selector) || {}).textContent; +} + })();