Many websites and web services make data available in XML format (as RSS, for example). In this recipe, will load an XML file, parse the contents, and display it within a text box.
1. In this example, we will use the following three files:
data.xml:
A very simple example XML data file with the following contents:<?xml version="1.0" encoding="UTF-8" ?> <list> <item>Item One</item> <item>Item Two</item> <item>Item Three</item> <item>Item Four</item> <item>Item Five</item> <item>Item Six</item> <item>Item Seven</item> <item>Item Eight</item> <item>Item Nine</item> <item>Item Ten</item> </list>
datasource_xml.php:
A PHP page with an input button for initiating the request and a text area to display the results:<?php require_once(dirname(__FILE__) . '/../config.php'); $PAGE->set_context(get_context_instance...