Xml file and JSON text to JavaScript object Program
What is Xml?
Xml stands X
for eXtensible M
for Markup L
for Language.
XML is a self-descriptive language for storing
and transporting data. It is recommended by W3C(World Wide Web Consortium.)
Create XML file To stored student Information
<studentList>
<rno>1</rno>
<name>ram</name>
<class>bcafy</class>
<Dob>11/1/2004</Dob>
<EmailId>ram@gmail.com</EmailId>
<rno>2</rno>
<name>rahim</name>
<Mobileno>bcafy</Mobileno>
<Dob>1/1/2004</Dob>
<EmailId>rahim@gmail.com</EmailId>
<rno>3</rno>
<name>Rocy</name>
<Dob>1/6/2004</Dob>
<EmailId>rocy@gmail.com</EmailId>
</studentList>
write a program to transform JSON text to a JavaScript object
<html>
<head>
<title>json</title></head>
<body>
<p id="show">
<p id="show1">
<script>
const jsonString = '{"name":"John", "age":30, "city":"New York"}';
const javascriptObject = JSON.parse(jsonString);
document.getElementById("show").innerHTML = jsonString.toString();
document.getElementById("show1").innerHTML = javascriptObject.name+ ' , ' +javascriptObject.age+ ' , ' +javascriptObject.city;
</script>
</body>
</html>
OUTPUT
{"name":"Ram Shastri", "age":20, "city":"Latur"}
Ram Shastri , 20 , Latur
Comments
Post a Comment