Hi WeedPacket,
Thank you for the reply. Indeed. In the example given I was trying to get one field, the tuition fee and see which tuition feel levels there are in the document. Adding the slashes did not give me any output. I have as good as no experience in XML processing, making this more dificult; I have no idea how PHP is accessing this.
If I use DOM manipulation, I can get things to work now;
function get_programme_info3($xmlUrl)
{
echo $xmlUrl."<br />";
$dom = new DomDocument();
$dom->load($xmlUrl);
// try something else
$params = $dom->getElementsByTagName('tuitionFee');
$k=0;
foreach($params as $fee)
{
$amounts = $params->item($k)->getElementsByTagName('amount');
$j = 0;
foreach($amounts as $amount)
{
echo "<br />TuitionFee: ".$amounts->item($j)->nodeValue;
$j++;
}
$k++;
}
}
This results in:
<br />http://www.hodexer.nl/hodex/uvt/hodex_nl_uvt_eb.xml<br />
<br />TuitionFee: 1672
<br />TuitionFee: 1972
<br />TuitionFee: 1972
<br />TuitionFee: 1713
<br />TuitionFee: 1713
<br />TuitionFee: 6546
However, that seems like a horrible way of doing it, if you are wanting to retrieve some 50 fields from the XML, and have a several hundreds of XML files to retreive, I think it will be fairly slow? Is this worry justified?
Is there a way to do this more efficiently, and code it in an efficient manner?
As said, in the end I will need a few dozen fields from the XML. I am going to put this all in one class 'ProgrammmeInformation', which should contain all the functions to retrieve the information from the XML. Would I need to create a function for each main node that I want to retrieve? Or would there be a clear way to recycle the function?
For example:
The tuitionFee node contains a number of nodes which I would need:
- amount
- tuitionFeeRate
- tuitionFeeType
- programForm
And then there might be a node LanguageRequirement, with 5 occurances each containing 2 fields to retreive:
languageExam
minimumScore