📁 AppML – Data Files: JSON, XML, and Text Format Support for Dynamic Web Apps
🧲 Introduction – Why Data File Support Matters in AppML
At the core of every AppML-powered application lies the data model—whether it’s a .json, .xml, or plain text file. AppML’s power lies in how it binds these external files directly to your HTML interface, letting you create interactive, data-driven apps without any JavaScript.
🎯 In this guide, you’ll learn:
- What types of data files AppML supports
- How to use JSON, XML, and text files with
appml-data - When to use each format and why
- Examples of rendering each data type using HTML
📦 Supported Data File Types in AppML
| 📂 File Type | ✅ Supported | 📘 Use Case |
|---|---|---|
.json | ✅ Yes | Preferred for structured data in arrays or objects |
.xml | ✅ Yes | Legacy systems and SOAP-based data services |
.txt | ✅ With formatting | Simple lists or delimited values (manual parsing required) |
.php/.asp | ✅ Yes | Server-side dynamic data (e.g., from databases) |
🧪 Example 1: Using a JSON File as a Data Model
✅ data/products.json
[
{ "name": "Phone", "price": 499 },
{ "name": "Laptop", "price": 999 }
]
✅ HTML View
<div appml-data="data/products.json">
<h3>{{name}}</h3>
<p>Price: ${{price}}</p>
</div>
💡 JSON is the most common and recommended format for AppML.
🧪 Example 2: Using XML Data
✅ data/employees.xml
<employees>
<record>
<name>Alice</name>
<email>alice@example.com</email>
</record>
<record>
<name>Bob</name>
<email>bob@example.com</email>
</record>
</employees>
✅ HTML View
<div appml-data="data/employees.xml">
<h4>{{name}}</h4>
<p>{{email}}</p>
</div>
💡 AppML will automatically convert XML <record> tags into usable data rows.
🧪 Example 3: Using a Text File (Limited Support)
✅ data/notes.txt
Meeting at 10 AM
Submit report by EOD
Team lunch on Friday
⚠️ Note: AppML does not parse plain text into objects. You must convert it to JSON or use a script to load and display it properly.
🔁 Use text files only when no structured fields are needed.
💻 Example: Using Server-Side PHP to Fetch Data
<?php
$data = [
["name" => "Monitor", "price" => 120],
["name" => "Keyboard", "price" => 50]
];
echo json_encode($data);
?>
Then, in your HTML:
<div appml-data="get-products.php">
<h3>{{name}}</h3>
<p>${{price}}</p>
</div>
✅ This allows you to fetch live, database-driven data with AppML.
🤔 When to Use JSON, XML, or Text in AppML?
| Format | Best Used For | Avoid When |
|---|---|---|
| JSON | Modern apps, API responses, tabular data | N/A |
| XML | Legacy systems, SOAP-based apps | You need simpler syntax |
| Text | Simple messages, notes | You need structured fields |
📌 Summary – Recap & Key Takeaways
Understanding how AppML works with different data file types is key to choosing the right structure for your application. JSON is your go-to format for speed, readability, and compatibility. XML is supported for older systems, and text files are suitable for basic content.
🔍 Key Takeaways:
- AppML works best with
.jsonand.xmlfiles - Use
appml-datato fetch and render file contents - Convert text or database output to JSON for better rendering
- Combine with controllers for filtering and advanced behavior
⚙️ Whether you store your data locally or retrieve it dynamically, AppML’s file flexibility makes it easy to integrate.
❓ FAQs – AppML Data Files
❓ Which data format is best for AppML apps?
✅ JSON is the most efficient and readable option for structured data in AppML.
❓ Can I bind data from a plain text file in AppML?
⚠️ Only basic text display is possible. You should convert text to JSON or XML for structured binding.
❓ Does AppML support real-time data from APIs?
✅ Yes, if the API returns JSON and CORS is enabled. Use appml-data="https://api.example.com/data".
❓ Can I use both JSON and XML in the same AppML page?
✅ Absolutely. Multiple appml-data blocks can coexist, each using different file types.
❓ Do I need a server to use these data files?
✅ Static .json and .xml files work without a server, but for .php or database-powered data, a local or web server is needed.
Share Now :
