sql - jQuery - changing XML & passing it (changed) to a function -
i have following jquery code in function.
var msgxml = "<xmlinput><source></source><messagetext></messagetext><sendtime></sendtime><destination></destination><notused></notused></xmlinput>", msgxmldoc = $.parsexml(msgxml), $msgxml = $( msgxmldoc ), $msgsource = $msgxml.find("source"), $msgtext = $msgxml.find("messagetext"), $msgstime = $msgxml.find("sendtime"), $msgdest = $msgxml.find("destination");
in function, need make changes each of nodes in xml, , when complete, pass changed xml ajax call that take xml input sql stored procedure.
in code below, can append xml values
$msgxml.children(0).append($msgsource.text(mysource)); $msgxml.children(0).append($msgtext.text(mymsg)); $msgxml.children(0).append($msgstime.text(currtimestring)); $msgxml.children(0).append($msgdest.text(mydest));
but changes xml structure (i not set field <notused></notused>
must pass it) , shuffles around xml. first issue/question.
the desired structure is:
<xmlinput> <source></source> <messagetext></messagetext> <sendtime></sendtime> <destination></destination> <notused></notused> </xmlinput>
using append above appears change values of node if put in console log:
console.log("out = " + $msgxml.find("source").text());
however, data that's being passed isn't gets written sql table. second issue. in console log, it's showing either undefined or [object object]. can display (changed) text, i'm not referencing xml structure properly. doing wrong each of these?
use
$msgxml.find("source").append(mysource);
instead of
$msgxml.children(0).append($msgsource.text(mysource));
(similarly other parts). $msgxml.children(0)
seems refer xmlinput
element logical start xml document node.
Comments
Post a Comment