bb.xml.serialization

In BB 3.x we were able to send the content of a node by using

<s:task b:action="send" b:url="saveform" b:source="id('mainDiv')" b:autoroot="true" b:destination="$tempResponseStore"/>

We were advised that bb.xml.serializtion was the way to go in 4.1.2 but whenever we use
bb.xml.serialize(bb.document.getElementById('mainDiv'),false)

the result comes as 'undefined'

A simple example below illustrates the problem.

<div>
<e:handler event="click" type="text/javascript">
bb.console.dirxml(bb.document.getElementById('pat'));
alert(bb.xml.serialize(bb.document.getElementById('pat'),false));
</e:handler>
<div id='pat'>ola <span> hello </span>
</div>
</div>

What are we missing?

use viewNode or modelNode

Hello risala,

when you use bb.document.getElementById('pat'), you are getting a Controler object, that don't have a direct xml representation.

You must use the modelNode or viewNode property of your div :

  alert(bb.xml.serialize(bb.document.getElementById('pat').viewNode,false));

Anyone know the use of XMLSerializer.serializeToString? this don't work for me.

use viewNode or modelNode

Hi huanho,

Try this one.This works for me.

var s = new XMLSerializer();                    alert(s.serializeToString(bb.document.getElementById('pat').viewNode));

~Yudi

Global Object

Ok, thanks Yudi.

It's clear, i don't tried to create a new instance. I think the reference is confusing, appear the following sentence , "XMLSerializer is a global JavaScript object"

But thank for your help, is only a suggestion :D