-
Notifications
You must be signed in to change notification settings - Fork 0
/
car.js
32 lines (16 loc) · 955 Bytes
/
car.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let opDiv = document.getElementById('d1')
document.querySelector('button').addEventListener('click', function () {
let number = document.querySelector('input').value
let username = "abhi-123"
let url = encodeURI(`http://www.regcheck.org.uk/api/reg.asmx/CheckIndia?RegistrationNumber=${number}&username=${username}`);
let request = new XMLHttpRequest();
console.log(url);
request.open("GET", url)
request.send()
request.onload = () => {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(request.response, "text/xml");
const jsondata = JSON.parse(xmlDoc.getElementsByTagName("vehicleJson")[0].textContent)
opDiv.innerHTML = `Model: ${jsondata.CarModel.CurrentTextValue}<br>Owner: ${jsondata.Owner}<br>Location: ${jsondata.Location}<br>Reg Date: ${jsondata.RegistrationDate}<br>Variant: ${jsondata.Variant}<br>Vehicle type:${jsondata.VehicleType}`
}
})