I have to read an XML file that resides on Fitnesse Page.
Let's take an example.
<?php
$url = http://localhost:9090/TestSuite.Fitnesse?Suite&Format=XML;
$xml=file_get_contents($url);
?>
My XML is in form of:
<xml version="some version">
<Results>
<name>Karan</name>
</Results>
...etc...
When I output the $xml
on page, some strange numbers appears to come before each and every tag and output seems to be like
37 9 Karan 9f .........and so on....
When I checked the source of that webpage, the page containes the below code:
37 9
<?XML Version="some version">
32
<Results>
32
<name>
45
Karan
0f
</name>
and so on....
(I didn't use the exact value, I can provide if needed).
Can anybody help me on this as I was not expecting these strange characters in output string.
You need to have allow_fopen_url set in your server (php.ini) for this to work.
If you don´t, then you can use this function as a replacement:
<?php
function curl_get_file_contents($URL)
{
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
?>
this will require curl extension enabled in your php.ini