Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 搜索XML文件_Javascript_Jquery_Xml - Fatal编程技术网

Javascript 搜索XML文件

Javascript 搜索XML文件,javascript,jquery,xml,Javascript,Jquery,Xml,我试图用从文本字段中获得的输入搜索xml文件。我可以在文件中循环并相互比较字符串,因此如果字符串完全相同,它们基本上是匹配的。我希望能够搜索一个词,并找到所有包含这个词的结果 换句话说,如果我搜索“lorem”,我希望它找到“lorem ipsum” 函数searchXML(){ $.get(“xml/resolvedisues.xml”,{},函数(xml){ 输入=document.getElementById(“inputSearch”).value; myHTMLOutput=''; m

我试图用从文本字段中获得的输入搜索xml文件。我可以在文件中循环并相互比较字符串,因此如果字符串完全相同,它们基本上是匹配的。我希望能够搜索一个词,并找到所有包含这个词的结果

换句话说,如果我搜索“lorem”,我希望它找到“lorem ipsum”

函数searchXML(){
$.get(“xml/resolvedisues.xml”,{},函数(xml){
输入=document.getElementById(“inputSearch”).value;
myHTMLOutput='';
myHTMLOutput+=“包含“”的票据”;
myHTMLOutput+=输入;
myHTMLOutput+=“”
$('Table1',xml).each(函数(i){
application=$(this.find(“application”).text();
module=$(this.find(“module”).text();
ticket=$(this).find(“ticket_x0023”)text();
summary=$(this.find(“summary”).text();
detail=$(this.find(“Details”).text();
problem=$(this).find(“problem_Flag”).text();
version=$(this.find(“version”).text();
build=$(this.find(“build”).text();
checked=$(this).find(“checked_In”).text();
status=$(this.find(“status”).text();
如果(输入==模块| |输入==票证| |输入==汇总||
输入==细节| |输入==问题| |输入==版本||
输入==生成| |输入==已检查| |输入==状态){
$('#demo').html('');
mydata=BuildTable(应用程序、模块、记录单、摘要、详细信息、问题、版本、构建、已检查、状态);
myHTMLOutput=myHTMLOutput+mydata;
};
});
$(“#演示”).append(myHTMLOutput);
});
}
不要这样做:

if (input == module || input == ticket || input == summary ||
    input == detail || input == problem || input == version ||
    input == build || input == checked || input == status) {
请尝试以下方法:

if ((module + ticket + summary + detail + problem + version +
    build + checked + status).indexOf(input) > -1) {
jQuery.contents() 描述:获取匹配元素集中每个元素的子元素,包括文本和注释节点


谢谢,这正是我想要的。indexOf()应该有大写字母“o”。哦,对不起,我已经修好了!
if ((module + ticket + summary + detail + problem + version +
    build + checked + status).indexOf(input) > -1) {