FalseAWS.MechanicalTurk.XMLParseErrorThere was an error parsing the XML question or answer data in your request. Please make sure the data is well-formed and validates against the appropriate schema. (1284779956270)Array00我正在尝试将整个电子邮件发送给机械土耳其人,并且我正在使用mtturk.lib.php库来发送此邮件。我尝试了urlencode和htmlentities来发送它,我确信有一个函数可以让这段代码“格式化得足够好”来发送它。
$thequestion = '<a href="linkgoeshere" target="_blank">click here</a>';
$QuestionXML = '<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
<Question>
<QuestionContent>
<Text>'.$thequestion.'</Text>
</QuestionContent>
<AnswerSpecification>
<FreeTextAnswer/>
</AnswerSpecification>
</Question>
</QuestionForm> ';发布于 2010-09-18 11:30:36
HTML不是XML的一种形式;不要试图这样解析它。最好的选择是使用HTML5解析器,或者,如果无法获得解析器,则使用SGML解析器。
发布于 2010-09-18 11:32:03
xml文档中的html代码可以通过多种方式嵌入:
htmlspecialchars()将其完全转义,并使用<![CDATA[ ... ]]>将其发送到XHTML,并在xmlns属性中指定正确的名称空间
不同的xml解析器可能支持也可能不支持第三种方法,我会选择第一种或第二种。
https://stackoverflow.com/questions/3740257
复制相似问题