I've recently started learning JavaScript and I'm facing some challenges while trying to reference an xml file uploaded by a user.
My goal is to eventually parse the XML contents, update them, and allow users to download the modified file.
Here's a snippet from my HTML file:
<div ng-controller = "myCtrl">
<input type="file" file-model="myFile"/>
<button ng-click="uploadFile()">Upload for Reading</button>
</div>
In controller.js:
myApp.controller('myCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){
$scope.uploadFile = function(){
var file = $scope.myFile;
console.log('file is ' + JSON.stringify(file));
parser=new DOMParser();
var xmlDoc=parser.parseFromString(file,"text/xml");
var length=xmlDoc.length;
console.log(length);
Result: file is {"name":"books.xml","lastModifiedDate":"2014-08-26T16:20:03.685Z","size":818,"type":"text/xml"}
length xmlDoc.length:undefined
However, it seems that xmlDoc.length is undefined in the result above.
Your assistance would be greatly appreciated.