AppML - Using XML
AppML application can read data using a xml file. Following is an example.
Step 1: Create Data
The first step is to create a xml based data file which will provide records to be displayed in application UI. Create a students-records.xml
students_records.xml
<?xml version="1.0" encoding="ISO-8859-1"?> <STUDENTS> <STUDENT> <NAME>Ramesh</NAME> <CLASS>12</CLASS> <SECTION>White</SECTION> </STUDENT> <STUDENT> <NAME>Suresh</NAME> <CLASS>12</CLASS> <SECTION>Red</SECTION> </STUDENT> <STUDENT> <NAME>Mohan</NAME> <CLASS>12</CLASS> <SECTION>Red</SECTION> </STUDENT> <STUDENT> <NAME>Robert</NAME> <CLASS>12</CLASS> <SECTION>Red</SECTION> </STUDENT> <STUDENT> <NAME>Julie</NAME> <CLASS>12</CLASS> <SECTION>White</SECTION> </STUDENT> <STUDENT> <NAME>Ali</NAME> <CLASS>12</CLASS> <SECTION>White</SECTION> </STUDENT> <STUDENT> <NAME>Harjeet</NAME> <CLASS>12</CLASS> <SECTION>White</SECTION> </STUDENT> </STUDENTS>
Step 2: Create Model
Create student_model.js file which will act as model to describe record.
{
"rowsperpage" : 7,
"data" : {
"type" : "xmlfile",
"filename" : "students_records.xml",
"record" : "STUDENT",
"items" : [
{"name" : "studentName", "nodename" : "NAME"},
{"name" : "class", "nodename" : "CLASS"},
{"name" : "section", "nodename" : "SECTION"}
]
}
}
student_application.html
<!DOCTYPE html>
<html lang="en-US">
<title>Students</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even) {background-color: #f2f2f2;}
</style>
<script src="https://www.w3schools.com/appml/2.0.3/appml.js"></script>
<body>
<table appml-data="appml.php?model=students_model">
<tr>
<th>Student</th>
<th>Class</th>
<th>Section</th>
</tr>
<tr appml-repeat="records">
<td>{{studentName}}</td>
<td>{{class}}</td>
<td>{{section}}</td>
</tr>
</table>
</body>
</html>
Output
Deploy the application on Web Server and access the html page. Verify the output.
appml_data.htm
Advertisements