virtualdevl Posted September 15, 2008 Share Posted September 15, 2008 Build and POST XML Hey guys, I am writing a small class to build and POST xml. I have a few XML requests that I have to build, i.e.: 1) getAuthKey 2) getUserInfo 3) getUserItems Now question is this, do I just write functions with the XML echoed out and then populate the values of the XML nodes from params passed in? Or should I build the XML depending on the request with a generic build XML function? This is for a client and since I haven't worked much with XML I would like to know what the industry standard is as I want it to be as professional as possible. Thanks, any input is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/124328-php-client-for-xml-api/ Share on other sites More sharing options...
Mchl Posted September 15, 2008 Share Posted September 15, 2008 Use one of PHP extensions for that. Your code will look cleaner and will be easier to extend later. Link to comment https://forums.phpfreaks.com/topic/124328-php-client-for-xml-api/#findComment-642130 Share on other sites More sharing options...
virtualdevl Posted September 15, 2008 Author Share Posted September 15, 2008 Mchl , thanks for the response, I am thinking of using simple xml or something, but what I need to know is if I should do as follows: function getAuthCode($param_1 = null, $param_2 = null) { $this->xml = "<rootNode>\n"; $this->xml .= "\t<request>getAuthCode</request>\n"; $this->xml .= "\t<child1>{$param_1}</child1>\n"; $this->xml .= "\t<child2>{$param_1}</child2>\n"; $this->xml .= "\t<child3>{$param_1}</child3>\n"; $this->xml .= "</rootNode>"; } and so forth for each request or should I not have the XML static and build it based on the request? I have to write an API client that POSTs this XML via HTTP. Link to comment https://forums.phpfreaks.com/topic/124328-php-client-for-xml-api/#findComment-642189 Share on other sites More sharing options...
virtualdevl Posted September 16, 2008 Author Share Posted September 16, 2008 Bump, anyone? Link to comment https://forums.phpfreaks.com/topic/124328-php-client-for-xml-api/#findComment-642787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.