如何将XML转换为HTML表,每行都有Reject和accept按钮

时间:2017-07-30 22:34:59

标签: javascript html xml xslt

我有一个作业,其中我有一个xml文件,其中包含有关新员工请求的信息。我必须以表格格式显示xml的每个条目,并在每个员工条目前面显示拒绝和接受按钮。当管理员点击拒绝时,应该从xml文件中删除该条目,如果管理员点击接受,那么条目应该存储在数据库的表中。 怎么办!!!请帮忙

编辑:我已经使用XSL在HTML页面中以表格格式表示XML

edit2:XML代码

List<Item>

XSL代码

<?xml version="1.0" encoding="UTF-8"?>
<entries>
  <reports>
    <name/>
    <email/>
    <phone/>
    <industry/>
    <message/>
    <website/>
    <engagement/>
    <urgency/>
    <type/>
    <specialization/>
    <customer_service/>
    <hr_service/>
    <mkt_service/>
    <sd_service/>
    <alliance_service/>
    <profile/>
    <suggest/>
  </reports>
  <reports>
    <timestamp>February 25, 2017, 1:05 pm</timestamp>
    <name>Rashmi</name>
    <email>rashmi.sri9@gmail.com</email>
    <phone>9900216479</phone>
    <industry>Arts and Entertainment</industry>
    <message>kjkj</message>
    <website>www.ccbul.com</website>
    <engagement>Education</engagement>
    <urgency>Education</urgency>
    <type>Implementer</type>
    <specialization/>
    <profile>/home/ccbul/public_html/dev/LocalTemp/project_detail/profile/Guideline To Use Task Manager2017-02-25_13:05:55.docx</profile>
  </reports>
  <reports>
    <timestamp>February 25, 2017, 1:10 pm</timestamp>
    <name>Rashmi</name>
    <email>rashmi.sri9@gmail.com</email>
    <phone>9900216479</phone>
    <industry>Arts and Entertainment</industry>
    <message>efef</message>
    <website>www.ccbul.com</website>
    <engagement>Education</engagement>
    <urgency>Education</urgency>
    <type>Implementer</type>
    <specialization>Chemical Process</specialization>
    <profile>/home/ccbul/public_html/dev/LocalTemp/project_detail/profile/Guideline To Use Task Manager2017-02-25_13:10:14.docx</profile>
  </reports>
</entries>

html页面中的Javascript代码

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <h2>Submitted Project details</h2>
  <div style="overflow-x:scroll">
  <table border="1">
    <tr bgcolor="#9acd32">
      <th style="text-align:left">name</th>
      <th style="text-align:left">e-mail</th>
      <th style="text-align:left">Phone</th>
      <th style="text-align:left">Industry</th>
      <th style="text-align:left">message</th>
      <th style="text-align:left">Website</th>
      <th style="text-align:left">engagement</th>
      <th style="text-align:left">urgency</th>
      <th style="text-align:left">type</th>
      <th style="text-align:left">specialization</th>
      <th style="text-align:left">customer service</th>
      <th style="text-align:left">hr service</th>
      <th style="text-align:left">mkt service</th>
      <th style="text-align:left">sd service</th>
      <th style="text-align:left">alliance service</th>
      <th style="text-align:left">profile</th>
      <th style="text-align:left">suggest.</th>
    </tr>
    <xsl:for-each select="entries/reports">
    <tr>
    <td><xsl:value-of select="name" /></td>
      <td><xsl:value-of select="email" /></td>
      <td><xsl:value-of select="phone" /></td>
        <td><xsl:value-of select="industry" /></td>
      <td><xsl:value-of select="message" /></td>
        <td><xsl:value-of select="website" /></td>
      <td><xsl:value-of select="engagement" /></td>
        <td><xsl:value-of select="urgency" /></td>
      <td><xsl:value-of select="type" /></td>

      <td><xsl:value-of select="specialization" /></td>
        <td><xsl:value-of select="customer_service" /></td>
      <td><xsl:value-of select="hr_service" /></td>
        <td><xsl:value-of select="mkt_servic" /></td>
      <td><xsl:value-of select="sd_service" /></td>
        <td><xsl:value-of select="alliance_service" /></td>
      <td><xsl:value-of select="profile" /></td>
        <td><xsl:value-of select="suggest" /></td>
    </tr>
    </xsl:for-each>
  </table>
  </div>
</xsl:template>

</xsl:stylesheet>

0 个答案:

没有答案