Hi All,
I need the javascript equivalent of:
<c:setText destination="$soapobject//test" select="'test'" mode="replaceChildren"/>
This piece of code puts 'test' inside the xml element test inside the variable soapobject.
I tried to do the following:
bb.command.setText(soapobject.getElementById('test'),'test','replaceChildren');
But this didn't work.
Any suggestions?
Lesley

Hi burger.lj Because "//"
17 January, 2008 - 15:20 — yudiHi burger.lj
Because "//" xpath expression select one node or more nodes , you have to use for loop otherwise it shows error.You can try the following example :)
....
var xpath= soapobject.selectNodes(".//test");
for( var i=0;i < xpath.length; i++){
bb.command.setText(xpath[i],'test','replaceChildren');
}
...
]]></e:handler>
hi yudi
25 January, 2008 - 13:02 — burger.ljHi Yudi,
Thanks for your reply.
I tested your code, but xpath[i] stays 'null'.
Do you have any idea why this could happen?
Thanks,
Lesley
xpath[i] stays 'null'
28 January, 2008 - 10:04 — yudiHi burger.lj,
It happens because it does not recognize the "soapobject" variable.The "xpath" itself comes from the "soapobject".That's why it said xpath[i] is null. You can debug the variable, if you want to check whether the variable is there or not by using alert(soapobject)or console.info(soapobject).
Hope this help,
Yudi
How do I alert an element inside soapobject?
6 February, 2008 - 13:17 — burger.ljHi Yudi,
Alerting soapobject works now (serialization did the trick).
If I alert soapobject, the alertbox displays [object]. If I serialize soapobject, the alertbox displays the xml.
Now I want to alert one element from soapobject.
Let's say soapobject//test. Without serialization, it displays 'null'. With serialization it says '' (nothing).
How do I get the value of soapobject//test? (it is not empty)
Thanks,
Lesley
Example
7 February, 2008 - 18:25 — jbrantlyHi Lesley,
Take a look at this code:
<b:button>
Click Me
<e:handler event="click" type="application/javascript"><![CDATA[
// Baseline
alert(bb.xml.serialize(xmldata));
// Set the text
bb.command.setText(bb.evaluateSmart('.//targetNode', xmldata), 'Text to insert', 'replaceChildren');
alert(bb.xml.serialize(xmldata));
// Alert the text
alert(bb.evaluateSmart('string(.//targetNode)', xmldata));
]]></e:handler>
</b:button>
It works
8 February, 2008 - 09:58 — burger.ljHi James,
It works now. I just had to change xmldata into vars['xmldata'].
Thanks for your help,
Lesley
Hmm... I don't have any idea
14 February, 2008 - 02:01 — uiiHmm... I don't have any idea for that... But You may check this http://www.pageresource.com/jscript/index.html tutorials... There I saw something like this. Good luck!