Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


How do I receive an XML file through HTTP?

How do I receive an XML file through HTTP?

How do I receive an XML file through HTTP?

Hi, I have PHP 4.0 so don't have simple XML.  I"m trying to use file_get_contents to read in the XML and then read the file till the end using fopen and other file commands.  Is this correct or does a file actually exist?  Thanks!
$xml = file_get_contents ('php://input') or die('file_get_contents (php://input)');

$fp = fopen($xml, 'r');

If I print the contents below using $HTTP_RAW_POST_DATA it displays the XML file that was posted

echo "<pre>";
print_r($HTTP_RAW_POST_DATA );
echo "</pre>";


RE: How do I receive an XML file through HTTP?

you seem to assuming that the xml is available at the standard input.  if you control the source of the xml or the receiving script, why not do the manipulations in that script rather than relying on sockets?

RE: How do I receive an XML file through HTTP?

Thanks.  The file xml file is sent by a 3rd party.  Now I'm trying to put it into a database.  I don't have access to simple xml or open xml.  In the code below it prints out the xml file correctly.  Here is the XML File.
$xml_data = "<?xml version=\"1.0\"?><member><Email>abc@home.com me</Email></member>";

How would I insert the email address into a database?  Even though the email address abc@home.com is printed out correctly as Email: abc@home.com I don't see how to capture that variable and put it into a database?  It's not $element_name since that's the field name.

//Function to use at the start of an element
function start($parser,$element_name,$element_attrs)
    case "EMAIL":
    echo "Email: ";    break;

RE: How do I receive an XML file through HTTP?

first of all migrate to php5.  php4 has been end of lifed. people should not be writing new code for a platform that no longer has support.

if you do not have any modern parsing extensions, then consider xml_parse_into_struct.

insert the values into the database in the normal way.

RE: How do I receive an XML file through HTTP?

Thanks.  I have no control over what my vendor has installed on their platform.  This includes no curl extension and no PHP 5.x

I'll check out the xml_parse_into_struct


RE: How do I receive an XML file through HTTP?

of course you have control.  just vote with your feet.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close