0

I have been scouring the internet trying to figure this one out. Any ideas would help. I'm trying to take an .xfdl file (base64gzip of XML) from my server and convert it to .xml with PHP for viewing and modification but, I can't see to figure out this process. I've seen people try to with Ruby but, I don't know any Ruby. If no one can help, I guess I'll be learning Ruby hahaha! Thanks in advanced. Also, I have looked through this website and couldn't find any php examples of this.

Higgsy
  • 324
  • 1
  • 14

1 Answers1

1

Assuming the XML is gzipped first and then base64 encoded, you can use base64_decode() and gzdecode().

echo gzdecode(base64_decode(file_get_contents('file.xfdl')));

However if you're not running on a Windows box, you will need to compile PHP with --with-zlib to include the zlib library and functions.

Once you have it in XML form, you might want to look at XMLReader to see how you can modify and read XML in PHP.

Bailey Parker
  • 15,599
  • 5
  • 53
  • 91
  • Don't laugh... I don't know how to complile PHP with `--with-zlib` or maybe I do and I'm not understanding you correctly. – Higgsy Jan 08 '12 at 18:04
  • @Cod-nerd Do you know how to use `phpinfo()`? If you're on shared hosting (or hosting where you didn't compile PHP), try saving this command in a file and viewing the file in your web browser. Do a quick search (Ctrl/Command + F) and see if you can find zlib anywhere on the page. – Bailey Parker Jan 08 '12 at 21:11
  • Ok. I see it on here. How do I enable it? I pulled my php.ini and it's not on there. – Higgsy Jan 08 '12 at 22:54
  • @Cod-nerd If you see it in phpinfo() then it probably is enabled. But just to make sure, try running `var_dump(function_exists('gzdecode'));` and see what that outputs. – Bailey Parker Jan 08 '12 at 22:57
  • @Cod-nerd Are you running your own setup with PHP or are you trying to run this in a shared hosting environment? If it's the latter you will need to contact your host to see if they can enable the zlib module in PHP. – Bailey Parker Jan 09 '12 at 00:21
  • Ok. yeah.. I'm currently using godaddy. But, when I can build a base, I plan on buying my own server. I'll contact them. Thanks for your help! – Higgsy Jan 09 '12 at 00:37