jquery - Storing HTML or XML code in javascript variables -
i'd store html/xml markups in javascript variable. problem text relatively large. example how can store following xml piece in javascript variable?
<questionform xmlns="[the questionform schema url]"> <overview> <title>game 01523, "x" play</title> <text> helping decide next move in game of tic-tac-toe. board looks this: </text> <binary> <mimetype> <type>image</type> <subtype>gif</subtype> </mimetype> <dataurl>http://tictactoe.amazon.com/game/01523/board.gif</dataurl> <alttext>the game board, "x" move.</alttext> </binary> <text> player "x" has next move. </text> </overview> <question> <questionidentifier>nextmove</questionidentifier> <displayname>the next move</displayname> <isrequired>true</isrequired> <questioncontent> <text> coordinates of best move player "x" in game? </text> </questioncontent> <answerspecification> <freetextanswer> <constraints> <length minlength="2" maxlength="2" /> </constraints> <defaulttext>c1</defaulttext> </freetextanswer> </answerspecification> </question> <question> <questionidentifier>likelytowin</questionidentifier> <displayname>the next move</displayname> <isrequired>true</isrequired> <questioncontent> <text> how player "x" win game? </text> </questioncontent> <answerspecification> <selectionanswer> <stylesuggestion>radiobutton</stylesuggestion> <selections> <selection> <selectionidentifier>notlikely</selectionidentifier> <text>not likely</text> </selection> <selection> <selectionidentifier>unsure</selectionidentifier> <text>it go either way</text> </selection> <selection> <selectionidentifier>likely</selectionidentifier> <text>likely</text> </selection> </selections> </selectionanswer> </answerspecification> </question> </questionform>
var string = (<r><![cdata[ text string goes here. since xml cdata section, stuff <> work fine too, if invalid xml. ]]></r>).tostring();
Comments
Post a Comment