简体   繁体   English

在不知道标签名称的情况下获取XML文件的所有节点

[英]Get all nodes of an XML file without knowing the tag names

I'm trying to load a url of an xml file into my page then use jQuery or ajax to load the 'text' from the xml into a string. 我正在尝试将xml文件的url加载到页面中,然后使用jQuery或ajax将xml中的“文本”加载到字符串中。 I do not know the attributes. 我不知道属性。 I've been trying this so far and it hasn't been working out: 到目前为止,我一直在尝试此方法,但尚未解决:

$(document).read(function){
                    $.get(infile, function(xml){
                    string = $(xml).text());
                    }
                }); 

                document.getElementById("input").innerHTML = string;

Any ideas? 有任何想法吗?

Your script has many errors. 您的脚本有很多错误。 Try this: 尝试这个:

$(document).ready(function(){
                $.get(infile, function(xml){
                  $("#input").text(xml);
                });
            }); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM