我有這樣的XML:更改XML的佈局 - 將XML元素值拆分爲多個元素;除去不必要的元素
<StockInfo>
<Item>
<stockcode>111111</stockcode>
<vehicle>Ford</vehicle>
<model>Escape (2000-)~Maverick (2001-)</model>
<width>8</width>
<wheel_size>18</wheel_size>
<offset>35</offset>
<bolt_pattermn>5x114.3</bolt_pattermn>
<brand>ANTERA</brand>
<Velg_ID/>
<kit1>DK-135259671 x1</kit1>
<kit2/>
<kit3/>
<kit4/>
<qty_available>3.00000000</qty_available>
<price>1110.00</price>
<picture>410110
</picture>
</Item>
<Item>
<stockcode>111111</stockcode>
<vehicle>Honda</vehicle>
<model>Civic (5skr,2001-2006)(2006-)~Accord (2003-2008)~Acord Coupe (1999-)~Acord Type R~Civic Type R (2001-2006)(2007-,17"<)~Civic Type S (2001-2006)(2007-,17"<)~Integra Type R~Prelude (1997-2001)~Legend (1991-1999)</model>
<width>8</width>
<wheel_size>18</wheel_size>
<offset>40</offset>
<bolt_pattermn>5x114.3</bolt_pattermn>
<brand>ANTERA</brand>
<Velg_ID/>
<kit1>DK-135259641 x1</kit1>
<kit2/>
<kit3/>
<kit4/>
<qty_available>3.00000000</qty_available>
<price>1110.00</price>
<picture>410110
</picture>
</Item>
<Item>
<stockcode>2222222</stockcode>
<vehicle>BMW</vehicle>
<model>6 (e63/64, 2004-2011)~M6 (e63/64, 2004-2011)</model>
<width>9</width>
<wheel_size>18</wheel_size>
<offset>15</offset>
<bolt_pattermn>5x120</bolt_pattermn>
<brand>AEZ</brand>
<Velg_ID>AEZ Ares</Velg_ID>
<kit1>DK-ZJB3 x1</kit1>
<kit2/>
<kit3/>
<kit4/>
<qty_available>4.00000000</qty_available>
<price>151110.00</price>
<picture>41001
</picture>
</Item>
</StockInfo>
正如所看到的有2相同的項(具有相同的stockcode;產品車車輪)和1個不同的項目...相同的項可以是X次(如果這個車輪適用於奧迪A3,奧迪A4,雪鐵龍X,它將成爲XML的3倍,所有其他元素(除了並具有相同的值))。
我的問題:
如何分離/分割元件
<model>
:<model>Civic (5skr,2001-2006)(2006-)~Accord (2003-2008)~Acord Coupe (1999-)~Acord Type R~Civic Type R (2001-2006)(2007-,17"<)~Civic Type S (2001-2006)(2007-,17"<)~Integra Type R~Prelude (1997-2001)~Legend (1991-1999)</model>
到X元素<model>
<model>Civic (5skr,2001-2006)(2006-)</model>
<model>Accord (2003-2008)</model>
<model>Acord Coupe (1999-)</model>
<model>Acord Type R</model>
<model>Civic Type R (2001-2006)(2007-,17"<)</model>
<model>Civic Type S (2001-2006)(2007-,17"<)</model>
<model>Integra Type R</model>
<model>Prelude (1997-2001)</model>
<model>Legend (1991-1999)</model>
分離符號「 〜」
到目前爲止我沒有能夠做到這一點(沒有使用PHP,既不XSL轉換),因此尋求幫助;-(
如何組具有相同
<stockode>
物品進入1<Item>
根代替的X? (如我所說,如果車輪適用於很多車型,那麼它將在XML中多次使用不同的正義元素(有時也是<vehicle>
- 但是在這個車輪的情況下也是如此)。僅適用於少數車型))?
因此,修改後的XML應該是:
<StockInfo>
<Item>
<stockcode>111111</stockcode>
<vehicle>Ford</vehicle>
<model>Escape (2000-)~Maverick (2001-)</model>
<vehicle>Ford</vehicle>
<model>Civic (5skr,2001-2006)(2006-)</model>
<model>Accord (2003-2008)</model>
<model>Acord Coupe (1999-)</model>
<model>Acord Type R</model>
<model>Civic Type R (2001-2006)(2007-,17"<)</model>
<model>Civic Type S (2001-2006)(2007-,17"<)</model>
<model>Integra Type R</model>
<model>Prelude (1997-2001)</model>
<model>Legend (1991-1999)</model>
<wheel_size>18</wheel_size>
<offset>35</offset>
<offset>40</offset>
<bolt_pattermn>5x114.3</bolt_pattermn>
<brand>ANTERA</brand>
<Velg_ID/>
<qty_available>3.00000000</qty_available>
<price>1110.00</price>
<picture>410110
</picture>
</Item>
<Item><stockcode>2222222</stockcode>
<vehicle>BMW</vehicle>
<model>6 (e63/64, 2004-2011)</model>
<model>M6 (e63/64, 2004-2011)</model>
<model>M6 (e63/64, 2004-2011)</model>
<width>9</width>
<wheel_size>18</wheel_size>
<offset>15</offset>
<bolt_pattermn>5x120</bolt_pattermn>
<brand>AEZ</brand>
<Velg_ID>AEZ Ares</Velg_ID>
<qty_available>4.00000000</qty_available>
<price>151110.00</price>
<picture>41001
</picture>
</Item>
</StockInfo>
你有什麼問題嗎? –
編輯後更清晰我的問題! –