I notice a lack of a format: indented, real xml
$ w3m -dump 'http://transgender-taiwan.org/api.php?action=query&meta=siteinfo&sip...' | sed '/^</,$!d' > What_I_want.xml
$ wget -O Almost_what_I_want_but_somebody_stripped_all_the_indentation.xml \ 'http://transgender-taiwan.org/api.php?action=query&meta=siteinfo&sip...'
I.e., if dumpBackup.php and Special:Export produce it, so should the API.
jidanni@jidanni.org schreef:
I notice a lack of a format: indented, real xml
$ w3m -dump 'http://transgender-taiwan.org/api.php?action=query&meta=siteinfo&sip...' | sed '/^</,$!d' > What_I_want.xml
$ wget -O Almost_what_I_want_but_somebody_stripped_all_the_indentation.xml \ 'http://transgender-taiwan.org/api.php?action=query&meta=siteinfo&sip...'
I.e., if dumpBackup.php and Special:Export produce it, so should the API.
First, for the record, non-indented XML without newlines is just as 'real' as indented XML.
Non-fm formats are not indented because they're not meant for display, and because stripping indentation reduces the size of the output, saving bandwidth (it may not seem like much for one small request like this one, but for many and/or large requests, it certainly makes a difference). Besides, bots don't (or at least shouldn't) care about indentation. The fm formats are indented and highlighted because they're meant to be used by humans, who do like indentation.
If your desire for indented XML is for viewing of downloaded XML, just open your XML file in Firefox. For other purposes, you could look for an XML prettifier, which I'm sure has to be available somewhere.
Roan Kattouw (Catrope)
On Mon, Jan 12, 2009 at 12:27:20PM +0100, Roan Kattouw wrote:
and because stripping indentation reduces the size of the output, saving bandwidth (it may not seem like much for one small request like this one, but for many and/or large requests, it certainly makes a difference).
It also saves a slight bit of CPU time, because the generating code doesnt have to track indentation levels or add the spaces for indenting.
If your desire for indented XML is for viewing of downloaded XML, just open your XML file in Firefox. For other purposes, you could look for an XML prettifier, which I'm sure has to be available somewhere.
You can throw one together easily enough in PHP, if your local PHP has the DOM extension enabled: Just load the API output into a new DOMDocument, set the formatOutput property to a true value, and save it. You should be able to do the same using the XML libraries in just about any other language.
mediawiki-api@lists.wikimedia.org