Closed (fixed)
Project:
Http Client
Version:
6.x-2.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
4 Oct 2010 at 16:08 UTC
Updated:
22 Aug 2012 at 14:48 UTC
Jump to comment: Most recent file
The XML Formatter always adds a tag called 'result' to any XML requests made. This is often undesirable in client software and I presume it's a throwback to the XML Formatter's original purpose as a response formatter. This feature should either be a) removed or b) made configurable either by a specific property on the formatter, or smarter detection of an appropriate root element from the input data.
A patch will be forthcoming, but I thought I'd kick off a debate about the best way to do it first.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | xml-formatter-root-element-name-931250-2.patch | 3.38 KB | Hugo Wetterberg |
| #1 | HttpClientXMLFormatter.inc_.root_.patch | 1.09 KB | Rob Knight |
Comments
Comment #1
Rob Knight commentedI've attached a patch which does the following:
If $data is an array with a single element, and that element has a non-numeric key, treat the key as the tag to be used for the root XML node, and the element will be used as the data. In other words:
should yield the XML:
This solves the problem whereby a element would always be used as the root node of the XML document, even when this was not desired.
I'm posting this as a patch, but I think it's an open question as to whether this should be implemented as an alternative formatter class. I'm happy for the maintainer(s) decide what they want :-)
Comment #2
Hugo Wetterberg commentedHi Rob, sorry about the lack of action in the issue queue. Here's an expanded patch that makes the XmlFormatter configurable, with options to change the default root element name and/or use an adaptive root name. Both are opt in features configurable through the constructor with backwards compatible defaults.
It would be great if you could give it a spin, nobody here uses XML, so any feedback is appreciated.
Comment #3
Hugo Wetterberg commentedComment #4
Hugo Wetterberg commentedFixed in 2.3