Last active
November 25, 2022 09:47
-
-
Save yushulx/a5f07891d5b22cfd24f21a111c80a008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<script src="https://code.jquery.com/jquery-3.4.1.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@7.2.3-v2/dist/dbr.js" | |
data-productKeys="PRODUCT-KEY"></script> | |
<input id="uploadImage" type="file" accept="image/bmp,image/jpeg,image/png,image/gif"> | |
<p id="results"></p> | |
<script> | |
document.getElementById('uploadImage').addEventListener('change', async function () { | |
$("#results").empty(); | |
var files = this.files; | |
let reader = await Dynamsoft.BarcodeReader.createInstance(); | |
let results = await reader.decode(files[0]); | |
if (results.length == 0) { | |
$("#results").append('No barcode detected!'); | |
return; | |
} | |
for (let result of results) { | |
console.log(result.barcodeText); | |
try { | |
xmlDoc = $.parseXML(result.barcodeText), | |
$(xmlDoc).each(function (i, obj) { | |
console.log(i); | |
console.log(obj.documentElement.nodeName); | |
$data = $(xmlDoc).find(obj.documentElement.nodeName); | |
$data.each(function () { | |
$.each(this.attributes, function (i, attrib) { | |
var name = attrib.name; | |
var value = attrib.value; | |
console.log(name); | |
console.log(value); | |
info = '<div>' + name + ': ' + value + '</div>'; | |
$("#results").append(info); | |
}); | |
}); | |
}); | |
} catch (error) { | |
$("#results").append(error.message); | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
thanks.
@vikas990 it doesn't matter. Since it's XML, you can use any pair of keys and values. If there's no standard, you have to check both loc and locality.
thanks.
its really usefull.
But, your source code is not working Bro..........
plz do it another way ohk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is very usefull but can you also explain that different aadhaar-card have different form of xml data how do we store all different type of data;
for example:-
in some aadhaar card location is stored as loc and in some locality how to solve that