Problems with file_get_contents()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pesho
Forum Newbie
Posts: 12
Joined: Fri Jan 27, 2006 9:43 am

Problems with file_get_contents()

Post by Pesho »

Hello,

for the last few hours I've been trying to solve the following problem, I couldn't figure it out.
I'm trying to obtain the XML content of a data provider...

However, the following code only returns the text between the xml tags:
echo file_get_contents("http://ir.ub.rug.nl/oai/?verb=ListRecor ... fix=oai_dc");


I need the whole xml structure though.

I'd appreciate if you could give me a hint about this.


Regards,
Pesho
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

The hole xml structure is there, you just need to view the source, because the browser is outputting it like text, so its ignoring the what it thinks are "html" brackets.

Code: Select all

<?php

// Just telling the browser its xml, to show you that its giving you everything
header("Content-type: text/xml");

echo file_get_contents("http://ir.ub.rug.nl/oai/?verb=ListRecords&metadataPrefix=oai_dc"); 

?>
-Zoxive
Last edited by Zoxive on Wed Mar 21, 2007 5:13 pm, edited 1 time in total.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

You are getting the whole XML, it's just that your browser is not showing the tags. View source and you'll see it's all there.
Ясно?
Pesho
Forum Newbie
Posts: 12
Joined: Fri Jan 27, 2006 9:43 am

Post by Pesho »

Thanks guys !!! и Благодаря :)
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

Post by harrisonad »

htmlentities() - Convert all applicable characters to HTML entities
Post Reply