Skip to content

Instantly share code, notes, and snippets.

@yushulx yushulx/aadhaar-card.html
Last active May 11, 2020

Embed
What would you like to do?
<!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>
@vikas990

This comment has been minimized.

Copy link

vikas990 commented May 10, 2020

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

@vikas990

This comment has been minimized.

Copy link

vikas990 commented May 10, 2020

thanks.

@yushulx

This comment has been minimized.

Copy link
Owner Author

yushulx commented May 11, 2020

@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.

@vikas990

This comment has been minimized.

Copy link

vikas990 commented May 11, 2020

thanks.
its really usefull.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.