简体   繁体   English

使用JavaScript从URL解析XML

[英]Parsing XML from URLwith javascript

I have an xml contained in a url. 我的网址中包含一个xml。 The xml contains information that I would like to access using javascript. xml包含我想使用javascript访问的信息。 In particular, I would like to access the record ID numbers. 特别是,我想访问记录ID号。 Any help would be appreciated. 任何帮助,将不胜感激。 The XML is contained here . XML包含在这里

The code I tried is as follows. 我尝试的代码如下。 However, it tells me that the url is an invalid argument. 但是,它告诉我url是无效的参数。

function importTable() {
    var response = UrlFetchApp.fetch("https://homesquare.quickbase.com/db/bij3xqndm?act=API_DoQuery&ticket=8_egp8sukxb_b2b92t_dmpt_a_dthwmsbdfjfzg5bfpsm3mbxnmaiddctskjbxw2t7zbmc8xambis3bkm&apptoken=5pvyk4bw5xdu2bct798ycgcibte&query={%27190%27.EX.%27%27}&clist=3.143&options=num-4");
    var doc = Xml.parse(response.getContentText(), true);
    Logger.log(response);
}

You may need to URL encode the curly braces in your URL. 您可能需要对URL中的花括号进行URL编码。 { = %7B and } = %7D {=%7B和} =%7D

For the XML traversal itself, I recommend the tutorial here: http://www.w3schools.com/xml/dom_nodes_traverse.asp 对于XML遍历本身,我推荐这里的教程: http : //www.w3schools.com/xml/dom_nodes_traverse.asp

The syntax is reasonably straightforward unless you have oddly named XML containers. 除非您的XML容器名称奇怪,否则语法相当简单。

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

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