oozcitak/xmlbuilder-js — Issue #16: Missing XML declaration with new root change
Author: baalexander
Created: 2011-11-28 20:48:57+00:00
State: open

First, thank you for the work on xmlbuilder. It's been hugely helpful.

I need toString() to include the XML declaration (e.g. ``). This was working until the recent change with the root method.

My [previous code](https://github.com/baalexander/node-xmlrpc/blob/e07645d5e1e06a5b32d5a406dffccdc4d72521f4/lib/xmlrpc-builder.js#L49,L58):

```javascript
var xml = xmlBuilder.create().begin('methodResponse', { version: '1.0' })
// ...Builds up XML...
// Prints ...
xml.up().toString()
```

I updated to v0.2.1 and received an error `This node has no parent`.

I tried updating the code to use root() instead of up() at the end like so:

```javascript
var xml = xmlBuilder.create().begin('methodResponse', { version: '1.0' })
// ...Builds up XML...
// Prints ...
xml.root().toString()
```

But root() prints the XML without the XML declaration. xml.root().up().toString() throws the same `This node has no parent` error and xml.root().prev() rightly complains no siblings.