diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
index a1e8fe03b..de832c4db 100644
--- a/chrome/content/zotero/xpcom/integration.js
+++ b/chrome/content/zotero/xpcom/integration.js
@@ -2996,21 +2996,19 @@ Zotero.Integration.DocumentData = function(string) {
* Serializes document-specific data as XML
*/
Zotero.Integration.DocumentData.prototype.serializeXML = function() {
- var xmlData =
-
-
-
- ;
-
+ var prefs = "";
for(var pref in this.prefs) {
- xmlData.prefs.pref +=
+ prefs += '';
}
- XML.prettyPrinting = false;
- var output = xmlData.toXMLString().replace("\n", "", "g");
- XML.prettyPrinting = true;
- return output;
+ return ''+
+ ''+
+ ''+
+ (prefs ? ''+prefs+'' : '')+'';
}
@@ -3018,18 +3016,18 @@ Zotero.Integration.DocumentData.prototype.serializeXML = function() {
* Unserializes document-specific XML
*/
Zotero.Integration.DocumentData.prototype.unserializeXML = function(xmlData) {
- if(typeof xmlData == "string") {
- var xmlData = new XML(xmlData);
- }
+ var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
+ .createInstance(Components.interfaces.nsIDOMParser),
+ doc = parser.parseFromString(xmlData, "application/xml");
- this.sessionID = xmlData.session.@id.toString();
- this.style = {"styleID":xmlData.style.@id.toString(),
- "hasBibliography":(xmlData.style.@hasBibliography.toString() == 1),
- "bibliographyStyleHasBeenSet":(xmlData.style.@bibliographyStyleHasBeenSet.toString() == 1)};
+ this.sessionID = Zotero.Utilities.xpathText(doc, '/data/session[1]/@id');
+ this.style = {"styleID":Zotero.Utilities.xpathText(doc, '/data/style[1]/@id'),
+ "hasBibliography":(Zotero.Utilities.xpathText(doc, '/data/style[1]/@hasBibliography') == 1),
+ "bibliographyStyleHasBeenSet":(Zotero.Utilities.xpathText(doc, '/data/style[1]/@bibliographyStyleHasBeenSet') == 1)};
this.prefs = {};
- for each(var pref in xmlData.prefs.children()) {
- var name = pref.@name.toString();
- var value = pref.@value.toString();
+ for each(var pref in Zotero.Utilities.xpath(doc, '/data/prefs[1]/pref')) {
+ var name = pref.getAttribute("name");
+ var value = pref.getAttribute("value");
if(value === "true") {
value = true;
} else if(value === "false") {
@@ -3039,8 +3037,10 @@ Zotero.Integration.DocumentData.prototype.unserializeXML = function(xmlData) {
this.prefs[name] = value;
}
if(this.prefs["storeReferences"] === undefined) this.prefs["storeReferences"] = false;
- this.zoteroVersion = xmlData["@zotero-version"].length() ? xmlData["@zotero-version"].toString() : "2.0";
- this.dataVersion = xmlData["@data-version"].length() ? xmlData["@data-version"].toString() : 2;
+ this.zoteroVersion = doc.documentElement.getAttribute("zotero-version");
+ if(!this.zoteroVersion) this.zoteroVersion = "2.0";
+ this.dataVersion = doc.documentElement.getAttribute("data-version");
+ if(!this.dataVersion) this.dataVersion = 2;
}
/**