Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-19-2012, 05:59 PM   PM User | #1
surreal5335
Regular Coder

 
Join Date: May 2008
Posts: 446
Thanks: 23
Thanked 5 Times in 5 Posts
surreal5335 is an unknown quantity at this point
put failed with curl and simplexml

I am using curl to put an update to an xml file which is made into an simpleXML object then I use asXML() before putting the file to curl.

I have a three function setup for this:
>>get with a curl (works fine)
>>process data with simpleXML (maybe causing problems)
>>putting info with curl (works fine when used on other simpleXML calls)

I should note that the get and put with curl functions are being reused and succeed in all other cases I use it.

I just one unique function for this particular simpleXML call which does the processing. I am currently getting a 400 error when I try to put with curl (this is the most info I have at this point)

Here is my unique simpleXML process function:
PHP Code:
function processData($result$value)
{
    
    
$xml = new SimpleXMLElement($result);
    
$newXML =     '<&quest;xml version="1.0" encoding="UTF-8" standalone="yes"&quest;>
        <subscription xmlns="http://domain.com">
            <status>'
.$xml->status.'</status>
            <data>'
.$value.'</data>
            <id>'
.$xml->id.'</id>
            <card>
                <last-four>'
.$xml->card->{"last-four"}.'</last-four>
                <type>'
.$xml->card->type.'</type>
            </card>
            <charge>
                <currency>'
.$xml->{"charge"}->currency.'</currency>
                <amount>9.99</amount>
            </charge>
            <charge-frequency>'
.$xml->{"charge-frequency"}.'</charge-frequency>
            <date>'
.$xml->date.'</date>
            <auto-renew>'
.$xml->{"auto-renew"}.'</auto-renew>
            <last-charge-result>
                <result-code>'
.$xml->{"last-charge-result"}->{"result-code"}.'</result-code>
            </last-charge-result>
        </subscription>'
;
    
    
$newSimpleXML = new SimpleXMLElement($newXML);
    
    
$newSimpleXML->data $value;
    
$newXML $newSimpleXML->asXML();
    echo 
'$value is: "'.$value.'"<br />';
    echo 
'new status is: '.$newSimpleXML->data.'<br />';
    echo 
'The data was: '.$xml->data;

    return 
$newXML;


the $result is derived from the get curl function, I have checked the output it is getting all the info I need





I appreciate any help in the matter

Last edited by surreal5335; 06-19-2012 at 06:09 PM..
surreal5335 is offline   Reply With Quote
Old 06-19-2012, 07:36 PM   PM User | #2
Alex Vincent
Moderator


 
Join Date: May 2002
Location: Hayward, CA
Posts: 1,427
Thanks: 1
Thanked 19 Times in 17 Posts
Alex Vincent is on a distinguished road
Why the &quest; entities? Why not use a simple question mark? Have you tried removing the XML prolog entirely?
__________________
"The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
June 30, 2001
author, Verbosio prototype XML Editor
author, JavaScript Developer's Dictionary
https://alexvincent.us/blog
Alex Vincent is offline   Reply With Quote
Old 06-19-2012, 07:45 PM   PM User | #3
surreal5335
Regular Coder

 
Join Date: May 2008
Posts: 446
Thanks: 23
Thanked 5 Times in 5 Posts
surreal5335 is an unknown quantity at this point
I out the &quest entities in so the [PHP] would not get thrown off and would continue reading the rest of the code as php.

I have tried without the prolog still I get the same result.

I also have simplified it down to using poster for firefox, to get a simplified result, but still I dont get anything good. Just a 404 error
surreal5335 is offline   Reply With Quote
Old 06-20-2012, 12:05 AM   PM User | #4
Alex Vincent
Moderator


 
Join Date: May 2002
Location: Hayward, CA
Posts: 1,427
Thanks: 1
Thanked 19 Times in 17 Posts
Alex Vincent is on a distinguished road
Ah, yes, short_open_tags... I'd forgotten about that. (That's what causes <?xml ?> to be read as PHP code.)

We might need a little bit more code - specifically, how you're calling processData(). Also, are you really using HTTP PUT or HTTP POST?
__________________
"The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
June 30, 2001
author, Verbosio prototype XML Editor
author, JavaScript Developer's Dictionary
https://alexvincent.us/blog
Alex Vincent is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:32 AM.


Advertisement
Log in to turn off these ads.