Jump to content

Reading XML Response


Dustin013

Recommended Posts

What is the correct method for reading an xml response from a server that replies using a small XML file in response to a post request sent from a form?

<!DOCTYPE response SYSTEM "https://blah/ap/dtd/response-v2.dtd">
<response>
    <result>success</result>
    <data>data here</data>
    <Id>0000</Id>
    <url><![CDATA[https://blahblah.com/lead?action=show&variable=0000]]></url>
</response>

Link to comment
Share on other sites

Ok, I have a form, it makes a post to a URL, can you give me an example of how I am going to be able to get the script to read the response? I can see the response as shown above in Firebug, but I am trying to figure out how to get the script that is submitting the form to read the response. I know how to parse the data but not exactly sure how to grab the information the server is responding with.

Link to comment
Share on other sites

Your script really needs to act as a client, submitting the form contents via a POST and then accepting the response from the server.  This is quite complicated stuff.  The best advice I have is to use PHP's curl integration. 

 

http://www.php.net/curl

 

 

Basically what you would need to do:

 

1. Form posts either to itself or to another script

2. Use Curl to re-post to the target server

3. Curl will let you read the response data

4. Parse that into something you can use with simplexml or whatever other PHP/xml solution suites you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.