Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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解析异常行为LiScroll_Javascript_Jquery_Html_Css_Xml - Fatal编程技术网

Javascript XML解析异常行为LiScroll

Javascript XML解析异常行为LiScroll,javascript,jquery,html,css,xml,Javascript,Jquery,Html,Css,Xml,我从一些jquery xml解析中得到了意想不到的行为 我使用以下代码从服务器获取文件 $.ajax({ type: "GET", url: "//path/test.xml", dataType: "xml", success: function(xml) { //do stuff } 如果我直接从文件中获取数据并将其硬编码到我的JS中,那么它的性能就不符合预期。文件中的数据以表单形式显示 <?xml version="1.0" encoding="ut

我从一些jquery xml解析中得到了意想不到的行为

我使用以下代码从服务器获取文件

$.ajax({
    type: "GET",
    url: "//path/test.xml",
    dataType: "xml",
    success: function(xml) { //do stuff }
如果我直接从文件中获取数据并将其硬编码到我的JS中,那么它的性能就不符合预期。文件中的数据以表单形式显示

<?xml version="1.0" encoding="utf-8"?><ProductRates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Total="64" Region="UK"><ProductRate><Description>UAE - Dirham</Description><ProductType>CUR</ProductType><CurrencyCode>AED</CurrencyCode><Rate>5.4427</Rate></ProductRate><ProductRate><Description>Australia - Australia Dollar</Description><ProductType>CUR</ProductType><CurrencyCode>AUD</CurrencyCode><Rate>1.6726</Rate></ProductRate></ProductRates>

您的xml结构无效。您有两个打开的ProductRates元素

<ProductRates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Total="64" Region="UK">
<ProductRates>


检查有效xml的最佳方法是将输出保存到xml文件并在浏览器中打开。

很抱歉,这是一个输入错误,文件是有效的xml。啊,我明白了。刚刚在上面添加了一条评论。这些项目输出为
  • AED=5.4427
  • AUD=1.6726
  • BBD=2.8524
  • 例如,但它们是垂直堆叠的,我假设这是一个css问题,但无法跟踪。您必须在问题中转储css,以便我们了解发生了什么。听起来容器没有溢出,或者您的LIs没有浮动。我非常确定这与XML的解析方式有关,因为我已经再次检查并在测试服务器上运行了XML。使用硬编码的XML字符串也可以,所以我假设解析XML文件时包含了一些内容,从而阻止了它的显示正确…您可以从浏览器复制输出吗?它可能是css,或者这些东西都被扔进了一个li。
    element.style {
    background-image: url(test.img);
    }
    Matched CSS Rules
    currency_ticker_test.shtmlmedia="all"
    #content-header {
    background-repeat: no-repeat;
    background-position: center top;
    }
    currency_ticker_test.shtmlmedia="all"
    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    font-size: 100%;
    vertical-align: baseline;
    background: transparent;
    }
    user agent stylesheetdiv {
    display: block;
    }
    Inherited from div#shell
    currency_ticker_test.shtmlmedia="all"
    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    font-size: 100%;
    }
    Inherited from body
    currency_ticker_test.shtmlmedia="all"
    body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: #2f2f2f;
    }
    currency_ticker_test.shtmlmedia="all"
    body {
    line-height: 1;
    }
    currency_ticker_test.shtmlmedia="all"
    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    font-size: 100%;
    }
    Inherited from html
    currency_ticker_test.shtml media="all"
    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    font-size: 100%;
    }
    
    <ProductRates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Total="64" Region="UK">
    <ProductRates>