我想在JavaScript變量中存儲一些HTML/XML標記。問題是文字比較大。例如,我如何將下面的XML片段存儲在一個JavaScript變量中?在JavaScript變量中存儲HTML或XML代碼
<QuestionForm xmlns="[the QuestionForm schema URL]">
<Overview>
<Title>Game 01523, "X" to play</Title>
<Text>
You are helping to decide the next move in a game of Tic-Tac-Toe. The board looks like 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, with "X" to move.</AltText>
</Binary>
<Text>
Player "X" has the next move.
</Text>
</Overview>
<Question>
<QuestionIdentifier>nextmove</QuestionIdentifier>
<DisplayName>The Next Move</DisplayName>
<IsRequired>true</IsRequired>
<QuestionContent>
<Text>
What are the coordinates of the best move for player "X" in this 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 likely is it that player "X" will win this game?
</Text>
</QuestionContent>
<AnswerSpecification>
<SelectionAnswer>
<StyleSuggestion>radiobutton</StyleSuggestion>
<Selections>
<Selection>
<SelectionIdentifier>notlikely</SelectionIdentifier>
<Text>Not likely</Text>
</Selection>
<Selection>
<SelectionIdentifier>unsure</SelectionIdentifier>
<Text>It could go either way</Text>
</Selection>
<Selection>
<SelectionIdentifier>likely</SelectionIdentifier>
<Text>Likely</Text>
</Selection>
</Selections>
</SelectionAnswer>
</AnswerSpecification>
</Question>
</QuestionForm>
究竟是什麼困難?您是否想知道格式(例如,作爲字符串還是DOM對象)?還有別的嗎? – outis 2011-02-26 06:51:38
我想找到最簡單的方法來存儲它作爲一個字符串。 – Mark 2011-02-26 07:19:02