相关疑难解决方法(0)

将XML展平为HTML表格

必须有一种通用的方法来转换某些层次XML,例如:

<element1 A="AValue" B="BValue">
   <element2 C="DValue" D="CValue">
      <element3 E="EValue1" F="FValue1"/>
      <element3 E="EValue2" F="FValue2"/>
   </element2>
   ...
</element1>
Run Code Online (Sandbox Code Playgroud)

进入扁平化的XML(html),沿途拾取所选属性,并为成为列标题的属性提供不同的标签.

<table>
   <tr>
     <th>A_Label</th>
     <th>D_Label</th>
     <th>E_Label</th>
     <th>F_Label</th>
   </tr>
   <tr>
     <td>AValue</td>
     <td>DValue</td>
     <td>EValue1</td>
     <td>FValue1</td>
   </tr>
   <tr>
     <td>AValue</td>
     <td>DValue</td>
     <td>EValue2</td>
     <td>FValue2</td>
   </tr>
<table>
Run Code Online (Sandbox Code Playgroud)

好的,所以由于属性重新标记,没有通用的解决方案,但你明白了我的意思.我刚刚开始使用所有的XSLT/XPATH,所以我会在适当的时候解决它,但任何线索都会有用.

xml xslt xpath

6
推荐指数
1
解决办法
7172
查看次数

标签 统计

xml ×1

xpath ×1

xslt ×1