[英]How do i parse the XML document in the callback?
我将responseXml作为javascript对象XMLdocument返回。 我如何解析它只是返回身体? 这是我的代码段:
goog.net.XhrIo.send("/blogs/create?authenticity_token="+
goog.string.urlEncode(authtoken), function(e) {
var xhr = /** @type {goog.net.XhrIo} */ (e.target);
var responseXml = xhr.getResponseXml();
var parent = goog.dom.getElement('response');
goog.dom.setTextContent(parent, responseXml.body); /** This returns
undefined rather than the body itself! */
}, 'POST', "&body="+goog.string.urlEncode(someHTMLContent), {
'Accept' : 'text/xml'
});
是的,您不需要进行任何解析。 您返回的responseXml
对象是一个Document对象( API docs ),因此您的responseXml.body
语法应该可以使用。 我不确定这里是什么问题。 如果您发布了一个在线示例,我们可以进一步调试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.