本文介绍了解析一个不寻常的xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 希望你们能提供帮助。试了一个多星期。使用Javascript不是很有经验。 我有一个xml文件,我通过终端仿真进行了检索。我想在html中将结果解析为textarea。我能够以xml格式查看textarea中的文件,但无法将其解析为内部文本的行。 这是javascript / jquery:Hope you guys can help. Trying for over a week. Not very experienced with Javascript.I have an xml file that I retreive via terminal emulation. I want to parse the results into a textarea in html. I am able to view the file in the textarea in xml format but have been unable to parse it into lines of the inner text.Here is the javascript/jquery:var x = ""var y = ""var Command="";var cmd=""$(document).ready(function() { alert('jquery working');$('#tester').click(function() { $("#disptext").val(""); var APOresp = new ActiveXObject("DAT32COM.TERMINALEMULATION"); var Command = "<FORMAT>>*IA</FORMAT>"; APOresp.MakeEntry(Command); //APOresp.GetMore(true,false); var x = APOresp.ResponseXML; APOresp.Close(); xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = "false"; xmlDoc.loadXML(x); $(x).find('RESPONSE').each(function() { $("#disptext").val($(this).text() + "<br />"); }); //$("#disptext").val(xmlDoc.xml);}); 这是xml文件的一小部分:Here is a small portion of the xml file:<?xml version="1.0"?><!--This is a host terminal response--><RESPONSE xmlns="x-schema:C:\fp\swdir\Content\emulation-schema.xml"> <LINE INDEX="1"><![CDATA[SIGN IN ]]><CARRIAGE_RETURN/></LINE> <LINE INDEX="2"><SOM/></LINE></RESPONSE> 我想得到LINE:标签的文本并将其循环到textarea中。如果我使用javascript文件中最后一个注释掉的行,它确实以xml格式放入整个xml文件。由于某些未知原因,我无法使用xmlDoc函数。我只是得到错误。任何帮助将不胜感激。在此先感谢。I want to get the text of the "LINE: tag and loop it into the textarea. It does put in the whole xml file in xml format if I use the last commented out line in the javascript file. For some unknown reason, I am unable to use the xmlDoc function. I just get errors. Any help would be greatly appreciated. Thanks in advance.推荐答案 这篇关于解析一个不寻常的xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 14:36