Permalink
Browse files

Changed XML formating to check number of top level items

Signed-off-by: Tom Densham <tom.densham@studiobonito.co.uk>
  • Loading branch information...
1 parent 9e91d77 commit 5cd77e70710024261622944885aabf350e73fd6e Tom Densham committed Dec 8, 2011
Showing with 13 additions and 2 deletions.
  1. +13 −2 classes/request/curl.php
View
@@ -269,8 +269,19 @@ protected function encode(array $input)
{
// Format as XML
case 'xml':
- $base_node = key($input);
- return \Format::forge($input[$base_node])->to_xml(null, null, $base_node);
+ /**
+ * If the input array has one item in the top level
+ * then use that item as the root XML element.
+ */
+ if(count($input) === 1)
+ {
+ $base_node = key($input);
+ return \Format::forge($input[$base_node])->to_xml(null, null, $base_node);
+ }
+ else
+ {
+ return \Format::forge($input)->to_xml();
+ }
break;
// Format as JSON

0 comments on commit 5cd77e7

Please sign in to comment.