Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.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/html格式和输出_Javascript_Html_Xml - Fatal编程技术网

Javascript Xml/html格式和输出

Javascript Xml/html格式和输出,javascript,html,xml,Javascript,Html,Xml,大家好,我对javascript/html/xml还不太熟悉,但我确实理解这些概念,并能做一些基本的编码 我试图获取一些xml数据,并将这些数据放入一些html表中,这一切都是可行的,但数据并没有被放入单独的表行中。我知道我可能需要创建数组,但我的代码是通过网络实现的,我一直在研究如何做到这一点。因此,我正在寻找有关javascript/html的帮助 它正在工作,但显示不正确,因为每个标题都在一行上,我需要它在单独的行上 我在谷歌上搜索过,尝试过各种选择,但运气不佳 javascript函数:

大家好,我对javascript/html/xml还不太熟悉,但我确实理解这些概念,并能做一些基本的编码

我试图获取一些xml数据,并将这些数据放入一些html表中,这一切都是可行的,但数据并没有被放入单独的表行中。我知道我可能需要创建数组,但我的代码是通过网络实现的,我一直在研究如何做到这一点。因此,我正在寻找有关javascript/html的帮助

它正在工作,但显示不正确,因为每个标题都在一行上,我需要它在单独的行上

我在谷歌上搜索过,尝试过各种选择,但运气不佳

javascript函数:

function myGetEventsXmlData() {
    $.ajax({
        type: "GET",
        url: "data/event_list.xml",
        dataType: "xml",
        success: xmlEventParser
    });
}

function xmlEventParser(xml) {
$(xml).find('event_list').each(function () {
    var $show = $(this);
    var data = {
        title: $show.find('title').text(),
        name: $show.find('name').text(),
        severity: $show.find('severity').text(),

    };
    var row = $('<tr />');
    for (var prop in data) {
        $('<td>' + data[prop] + '</td>').appendTo(row);
    }

    $('#eventtable').append(row);
});
}  
函数myGetEventsXmlData(){
$.ajax({
键入:“获取”,
url:“data/event_list.xml”,
数据类型:“xml”,
成功:xmlEventParser
});
}
函数xmlEventParser(xml){
$(xml).find('event_list')。每个(函数(){
var$show=$(此);
风险值数据={
标题:$show.find('title').text(),
名称:$show.find('name').text(),
严重性:$show.find('severity').text(),
};
变量行=$('');
用于(数据中的var prop){
$(''+数据[prop]+'')。附加到(行);
}
$('#eventtable')。追加(行);
});
}  
这是我试图解析的xml文件

<?xml version="1.0" encoding="UTF-8"?>
<event_list>
    <event>
        <id>9199acca-df09-71e6-1946-c0a800820000</id>
        <title>client.createConnection(691) - AMQ214016: Failed to create netty connection </title>
        <name>test1.system.com</name>
        <state>open</state>
        <severity>critical</severity>
        <priority>medium</priority>
        <category>Internal</category>
     </event>
     <event>
         <id>9199acca-df09-71e6-1946-c0a800820000</id>
         <title>ssh login failed </title>
         <name>test2.system.com</name>
         <state>open</state>
         <severity>major</severity>
         <priority>medium</priority>
         <category>OS</category>
     </event>
     <event>
         <id>9199acca-df09-71e6-1946-c0a800820000</id>
         <title>Oracle Connection OK </title>
         <name>test3.system.com</name>
         <state>open</state>
         <severity>normal</severity>
         <priority>medium</priority>
         <category>Database</category>
     </event>
 </event_list>

9199acca-df09-71e6-1946-c0a800820000
client.createConnection(691)-AMQ214016:未能创建netty连接
test1.system.com
打开
批评的
中等的
内部的
9199acca-df09-71e6-1946-c0a800820000
ssh登录失败
test2.system.com
打开
专业
中等的
操作系统
9199acca-df09-71e6-1946-c0a800820000
Oracle连接正常
test3.system.com
打开
正常的
中等的
数据库
html代码部分

              <table id="eventtable" table=table style="width:100%"               align="center">
            <tr>
                <th>Title</th>
                <th>Name</th>
                <th>Severity</th>

            </tr>
        </table>

标题
名称
严重程度
数据出现在部分中,但它是所有在一起的,而不是单独的行,我希望数据在每一个新数据的新行上,而不是在一行上

任何关于如何做到这一点的想法都会很好

您正在每个
上循环(其中只有一个)


你应该在每个

上循环,你没有说
#eventtable
是什么,但是,除非它是
tbody
thead
tfoot
,否则它不会起作用。它起作用了!!!!!,非常感谢您的回复,并知道如何…再次感谢您,兄弟!!:-)
$(xml).find('event_list').each(function () {