Reading XML with PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aggelos

    Reading XML with PHP

    Hello,
    First of all I want to say I do not have very clear understanding of
    XML and PHP and what you can do with those two.
    Now the problem I have is:
    There is that booking company that sends data to me via XML and I have
    in my server to read that XML and store it in a DB.
    What I have no Idea how to do is read that XML.
    To start with, I though they were using $_POST to upload an XML file,
    but it seems they do not as when I get a request in my script I
    print_r the $_POST and it is empty. The same with $_GET, empty.

    Do you have any idea of other ways that they might send the XML data
    and how can I read them with a PHP4 script?

    Thank you.

  • Mathias K.

    #2
    Re: Reading XML with PHP

    Am 16 Mar 2007 02:47:32 -0700 schrieb Aggelos:
    Hello,
    First of all I want to say I do not have very clear understanding of
    XML and PHP and what you can do with those two.
    Now the problem I have is:
    There is that booking company that sends data to me via XML and I have
    in my server to read that XML and store it in a DB.
    What I have no Idea how to do is read that XML.
    To start with, I though they were using $_POST to upload an XML file,
    but it seems they do not as when I get a request in my script I
    print_r the $_POST and it is empty. The same with $_GET, empty.
    >
    Do you have any idea of other ways that they might send the XML data
    and how can I read them with a PHP4 script?
    >
    Thank you.
    Hello Aggelos!

    First of all, a short tutorial about uploading (sending it to your server)
    files with PHP can be found there:


    When the file is stored on the server you can read it as usual with fopen,
    fread, fclose etc.

    Of course, if you want to parse the XML file that's a bit more complicated.
    I suggest you to look for a class on www.phpclasses.org

    A very good class that is also used by Joomla and Mambo CMS (among others)
    is DOMIT! XML Parser by John Heinstein:


    Good luck.


    ~ MK

    Comment

    • Aggelos

      #3
      Re: Reading XML with PHP

      OK Sollution to the problem found !!!
      ALl the data were coming to the following variable, and that's why I
      couldn't read them VIA $_POST
      $HTTP_RAW_POST_ DATA

      If you have any comments or suggestions, I will be happy to read
      them :)

      THank you.

      Comment

      • Aggelos

        #4
        Re: Reading XML with PHP

        >
        First of all, a short tutorial about uploading (sending it to your server)
        files with PHP can be found there:http://www.phpjabbers.com/file-uploa...php-php18.html
        >
        THank you but my problem was that they do not do a $_FILE post, just a
        $_POST of an XML string...
        ANd I caught that via $HTTP_RAW_POST_ DATA.
        :)

        Thanks for the parsing class tip though ;)



        Comment

        • Rik

          #5
          Re: Reading XML with PHP

          On Fri, 16 Mar 2007 12:26:31 +0100, Aggelos <djjelly@gmail. comwrote:
          OK Sollution to the problem found !!!
          ALl the data were coming to the following variable, and that's why I
          couldn't read them VIA $_POST
          $HTTP_RAW_POST_ DATA
          >
          If you have any comments or suggestions, I will be happy to read
          them :)
          Could be that they're sending you an XML-file rather then 'just' XML, then
          it would be in the $_FILES array.

          Also, reading php://input can be very handy to determine what the exact
          request was you received.
          --
          Rik Wasmus

          Comment

          Working...