xmlstarlet sel的“开始和结束标记不匹配”

时间:2019-11-01 22:10:24

标签: xml xml-parsing xmlstarlet

http://doi.cnki.net/Resolution/Handler?doi=10.13345/j.cjb.180087

在以下文件上运行const api_url = 'https://opensky-network.org/api/states/all?lamin=45.8389&lomin=5.9962&lamax=47.8229&lomax=10.5226'; $(document).ready(() => { $.get(api_url, ({ states }, status) => { const $data = $("#data"); // use forEach and destructure the columns data states.forEach(([col1, , col2, , , col3, col4, col5, , col6]) => { const cols = [col1, col2, col3, col4, col5, col6]; // combine to a single array $data.append( `<tr>${cols.map(c => `<td>${c}</td>`).join('')}</tr>` // iterate the cols and create the cells ); }); }) })时,出现以下错误消息。有人知道如何解决该问题吗?

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table id="data">
  <tr>
    <th>ICAO24</th>
    <th>CountryOrigin</th>
    <th>longitude</th>
    <th>latitude</th>
    <th>altitude</th>
    <th>velocity m/s</th>
  </tr>

</table>

1 个答案:

答案 0 :(得分:1)

您的HTML文件格式不正确。第77行的<img>元素

<img style="height: 24px; border: 0px none; vertical-align: middle;" src="/Content/images/gongshangbiaoshi.gif" alt="" class="footpic" >

未关闭。添加结束标记... />,使其格式正确

<img style="height: 24px; border: 0px none; vertical-align: middle;" src="/Content/images/gongshangbiaoshi.gif" alt="" class="footpic" />

然后输出将是:

  

iconSucc

编辑:

使用xmllint,您可以通过一个命令获得结果:

xmllint -html -xmlout Handler.xml | xmlstarlet sel -t -v '//i[@class = "iconSucc"]/@class'