【发布时间】:2017-07-28 03:28:04
【问题描述】:
我有这个带有表格的 XML,但我不知道如何在 PHP 中显示表格,html 无法将节点识别为表格。
我是否必须读取每个单独的节点并将其更改为
<?xml version="1.0" encoding="utf-8"?>
<afpdb lang="fr-FR">
<head>
<message type="203" file="s4133-0000000-203-fr" timestamp="2014-04-16T12:16:26+02:00" />
</head>
<body>
<competition id="866" label="Brésil 2014">
<discipline code="FB" name="Football">
<evt id="4133" label="Brésil 2014" gender="M" date="2014-06-12T00:00:00-03:00">
<country iso="BRA" code="BRA" name="Brésil" />
<phase id="2714" code="TP8FI" type="PH1PT">
<group id="9276" name="C" label="Groupe C">
<table type="TAFUL">
<thead>
<tcol num="1" type="TCVAL" code="CCPOS" />
<tcol num="2" type="TCXML" code="CCEQU" />
<tcol num="3" type="TCVAL" code="CCPTS" />
<tcol num="4" type="TCVAL" code="CCJOU" />
<tcol num="5" type="TCVAL" code="CCGAG" />
<tcol num="6" type="TCVAL" code="CCNUL" />
<tcol num="7" type="TCVAL" code="CCPER" />
<tcol num="8" type="TCVAL" code="CC_BP" />
<tcol num="9" type="TCVAL" code="CC_BC" />
<tcol num="10" type="TCVAL" code="CCDIF" />
</thead>
<trow>
<tcol num="1" val="1" />
<tcol num="2">
<team id="2090" type="CENAT" display="Brésil">
<country iso="BRA" code="BRA" name="Brésil" />
</team>
</tcol>
<tcol num="3" val="0" />
<tcol num="4" val="0" />
<tcol num="5" val="0" />
<tcol num="6" val="0" />
<tcol num="7" val="0" />
<tcol num="8" val="0" />
<tcol num="9" val="0" />
<tcol num="10" val="0" />
</trow>
<trow>
<tcol num="1" val="1" />
<tcol num="2">
<team id="2103" type="CENAT" display="Cameroun">
<country iso="CMR" code="CMR" name="Cameroun" />
</team>
</tcol>
<tcol num="3" val="0" />
<tcol num="4" val="0" />
<tcol num="5" val="0" />
<tcol num="6" val="0" />
<tcol num="7" val="0" />
<tcol num="8" val="0" />
<tcol num="9" val="0" />
<tcol num="10" val="0" />
</trow>
<trow>
<tcol num="1" val="1" />
<tcol num="2">
<team id="2107" type="CENAT" display="Croatie">
<country iso="HRV" code="CRO" name="Croatie" />
</team>
</tcol>
<tcol num="3" val="0" />
<tcol num="4" val="0" />
<tcol num="5" val="0" />
<tcol num="6" val="0" />
<tcol num="7" val="0" />
<tcol num="8" val="0" />
<tcol num="9" val="0" />
<tcol num="10" val="0" />
</trow>
<trow>
<tcol num="1" val="1" />
<tcol num="2">
<team id="2175" type="CENAT" display="Mexique">
<country iso="MEX" code="MEX" name="Mexique" />
</team>
</tcol>
<tcol num="3" val="0" />
<tcol num="4" val="0" />
<tcol num="5" val="0" />
<tcol num="6" val="0" />
<tcol num="7" val="0" />
<tcol num="8" val="0" />
<tcol num="9" val="0" />
<tcol num="10" val="0" />
</trow>
</table>
</group>
</phase>
</evt>
</discipline>
</competition>
</body>
</afpdb>
【问题讨论】:
-
您将需要一个 XML DOM 解析器。或者您可以编写一个 XSLT。没有“自动化”,或者说是自动化的方式。
-
在任何支持“查找和替换”功能 (CTRL+H) 的文本编辑器中打开此文件。这是一种简单的方法。
标签: php xml html-table