I need to get XML from a ODF file. I tried using FileReader readAsText and readAsBinaryString but its not working.
FileReader readAsText returns some special characters for odf files.
with readAsBinaryString
var reader = new FileReader()
reader.onloadend=function(e){
var data = e.target.result;
//data is not in xml format
var xml = str2xml(data);
//getting error
/*
using DOM parser for xml parsing
*/
}
reader.readAsBinaryString(file);
How can get XML from ODF file using javascript FileReader?
Using the response like text:
:)
If you need to load the xml like jquery object:
then you can use jquery selector's on
Here's a browser-based example, but this should be applicable to other JavaScript contexts:
Make a Form:
Handle the Upload: (I'm using JQuery for brevity/simplicity)
The
xmldata
variable contains your XML, ready for your magic.