javascript 解析 XML
搞了好几个小时 还是搞不定这个 在firefox中用一个user.js使用ajax提交服务器服务器返回内容
程序代码:
<?xml version="1.0" encoding="gbk"?> <root><![CDATA[<h3 class="flb"> <em id="return_reply"> 参与/回复主题</em> <span> <a href="javascript:;" class="flbc" onclick="hideWindow('reply')" title="关闭">关闭</a> </span> </h3> <form method="post" autocomplete="off" id="postform" action="forum.php?mod=post&infloat=yes&action=reply&fid=6&extra=page%3D1&tid=1452788&replysubmit=yes" onsubmit="this.message.value = parseurl(this.message.value);ajaxpost('postform', 'return_reply', 'return_reply', 'onerror');return false;"> <div class="c" id="floatlayout_reply"> <div class="p_c"> <input type="hidden" name="formhash" id="formhash" value="c6233642" /> <input type="hidden" name="handlekey" value="reply" /> <input type="hidden" name="noticeauthor" value="3508dW5XUU/a5kw0cYoy6G8socGi9WgWDO8uUC71sIbz41BT1w" /> <input type="hidden" name="noticetrimstr" value="" /> <input type="hidden" name="noticeauthormsg" value="不管怎么样.member这页必须要ssl保护 用户们的密码安全很重要 5年的ssl证书才155 RMB http://is.gd/ ..." /> <input type="hidden" name="reppid" value="27434874" /> <input type="hidden" name="reppost" value="27434874" /> <div class="pbt cl"> <span id="subjecthide" class="z">RE: 希望卡饭买个ssl证书 [<a href="javascript:;" onclick="display('subjecthide');display('subjectbox');$('subject').value='RE: 希望卡饭买个ssl证书'">修改</a>]</span> <span id="subjectbox" style="display:none"><input name="subject" id="subject" class="px" value="" tabindex="21" style="width: 25em" /></span> </div> <div class="tedt"> <div class="bar"> <span class="y"> <a href="http://bbs. onclick="switchAdvanceMode(this.href);doane(event);">高级模式</a> </span><script src="data/cache/seditor.js?IBO" type="text/javascript"></script> <div class="fpd"> <a href="javascript:;" title="文字加粗" class="fbld" onclick="seditor_insertunit('post', '', '');doane(event);">B</a> <a href="javascript:;" title="设置文字颜色" class="fclr" id="postforecolor" onclick="showColorBox(this.id, 2, 'post');doane(event);">Color</a> <a id="postimg" href="javascript:;" title="图片" class="fmg" onclick="seditor_menu('post', 'img');doane(event);">Image</a> <a id="posturl" href="javascript:;" title="添加链接" class="flnk" onclick="seditor_menu('post', 'url');doane(event);">Link</a> <a id="postquote" href="javascript:;" title="引用" class="fqt" onclick="seditor_menu('post', 'quote');doane(event);">Quote</a> <a id="postcode" href="javascript:;" title="代码" class="fcd" onclick="seditor_menu('post', 'code');doane(event);">Code</a> <a href="javascript:;" class="fsml" id="postsml" onclick="showMenu({'ctrlid':this.id,'evt':'click','layer':2});return false;">Smilies</a> <script type="text/javascript" reload="1">smilies_show('postsmiliesdiv', 8, 'post');</script> </div></div> <div class="area"> <textarea rows="7" cols="80" name="message" id="postmessage" onKeyDown="seditor_ctlent(event, '$(\'postsubmit\').click();')" tabindex="22" class="pt"></textarea> </div> </div> </div> </div> <div class="o pns" id="moreconf"> <button type="submit" id="postsubmit" class="pn pnc z" value="true" name="replysubmit" tabindex="23"><span>参与/回复主题</span></button> </div> </form> <script type="text/javascript" reload="1"> function succeedhandle_reply(locationhref, message) { try { var pid = locationhref.lastIndexOf('#pid'); if(pid != -1) { pid = locationhref.substr(pid + 4); ajaxget('forum.php?mod=viewthread&tid=1452788&viewpid=' + pid, 'post_new', 'ajaxwaitid', '', null, 'appendreply()'); if(replyreload) { var reloadpids = replyreload.split(','); for(i = 1;i < reloadpids.length;i++) { ajaxget('forum.php?mod=viewthread&tid=1452788&viewpid=' + reloadpids[i], 'post_' + reloadpids[i]); } } } else { showDialog(message, 'notice', '', 'location.href="' + locationhref + '"'); } } catch(e) { location.href = locationhref; } hideWindow('reply'); } if($('subjectbox')) { $('postmessage').focus(); } else if($('subject')) { $('subject').select(); $('subject').focus(); } </script>]]></root>
怎么才能获取到<input type="hidden" name="noticeauthor" value="3508dW5XUU/a5kw0cYoy6G8socGi9WgWDO8uUC71sIbz41BT1w" />中的value呢?
ajax回调函数:
程序代码:
sendAsynchronRequest(src.getAttribute("action_url"),null,function(){ try{ if (mykafanxmlHttp.readyState == 4) { if (mykafanxmlHttp.status == 200) { if(mykafanxmlHttp.responseText != null && mykafanxmlHttp.responseText != ""){ var root = mykafanxmlHttp.responseXML; root=root.getElementsByTagName("root")[0]; //var aaa=root; alert(root); } } } }catch(e){ alert(e); } });
好像因为CDATA的关系 我取不到里面的input了,要怎么才能解决这个?