How can I serialize rdf:bookmarks to string?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How can I serialize rdf:bookmarks to string?

gomita.mail
Hi all,

Is there a way to serialize Bookmarks datasource to XML source?

I followed the tutorial at
http://www.xulplanet.com/tutorials/mozsdk/rdfsave.php and tried the code
below using nsIRDFXMLSerializer.
However, nsIRDFXMLSource.Serialize returns NS_ERROR_FAILURE.

Thanks for  your help.

---
var rdfService =
Components.classes['@mozilla.org/rdf/rdf-service;1'].getService(Components.interfaces.nsIRDFService);
var ds = rdfService.GetDataSource("rdf:bookmarks");

var outputStream = {
   data: "",
   close : function(){},
   flush : function(){},
   write : function (buffer,count){
     this.data += buffer;
     return count;
   },
   writeFrom : function (stream,count){},
   isNonBlocking: false
}
var serializer =
Components.classes["@mozilla.org/rdf/xml-serializer;1"].createInstance(Components.interfaces.nsIRDFXMLSerializer);
serializer.init(ds);
serializer.QueryInterface(Components.interfaces.nsIRDFXMLSource);
serializer.Serialize(outputStream);
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf