I am uploading a zip folder and trying to read its XML file. The function can read the zip using JSZip but unable to retrieve the content of XML file.
readasText needs a blob object, I tried different things but it always gives type error.
upload: function (e) {
$("#fullPath").val(e.files[0].name);
if ($.browser.msie == undefined || ($.browser.msie && $.browser.version < 10) == false) {
$("#fullPath").val(e.files[0].name);
var zipFile = new JSZip();
zipFile.loadAsync(e.files[0].rawFile)
.then(function(zip) {
var reader = new FileReader();
reader.readAsText(zip.files);// type error: dont know how to access the xml file
reader.onloadend = function () {
GetValueFile(reader.result);
}
});
}
}
I want to give the XML result to the GetvalueFile function The file object is inside zip.files but I'm unable to retrive it.
I am uploading a zip folder and trying to read its XML file. The function can read the zip using JSZip but unable to retrieve the content of XML file.
readasText needs a blob object, I tried different things but it always gives type error.
upload: function (e) {
$("#fullPath").val(e.files[0].name);
if ($.browser.msie == undefined || ($.browser.msie && $.browser.version < 10) == false) {
$("#fullPath").val(e.files[0].name);
var zipFile = new JSZip();
zipFile.loadAsync(e.files[0].rawFile)
.then(function(zip) {
var reader = new FileReader();
reader.readAsText(zip.files);// type error: dont know how to access the xml file
reader.onloadend = function () {
GetValueFile(reader.result);
}
});
}
}
I want to give the XML result to the GetvalueFile function The file object is inside zip.files but I'm unable to retrive it.
Share Improve this question asked Jan 25, 2017 at 15:34 مسعودمسعود 68910 silver badges26 bronze badges1 Answer
Reset to default 6For anyone who might have the same problem
zip.files['test1.xml'].async("string")// gives the content of xml
It returns a promise which can be used to trigger further functions
.then(function(zip) {
zip.files['test1.xml'].async("string")
.then(function (data) {
GetValueFile(data);
});
});