程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> xml-一個XML文件編寫問題,麻煩各位

xml-一個XML文件編寫問題,麻煩各位

編輯:編程綜合問答
一個XML文件編寫問題,麻煩各位

我想實現一個商品的信息使用XML存放,具體信息大概如下,商品編號1、商品編號2,編號1下面有顏色1、顏色2,然後在顏色下面有尺寸與數量,大概的示例圖如下。示例圖

最佳回答:


一種:

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

<product>
<model>型號xxx</model>    
<name>商品1</name>
<color name="xxx">
<size name="89x28" number="88"/>
<size name="100x28" number="2"/>
</color>
<color name="yyy">
<size name="89x28" number="88"/>
<size name="100x28" number="2"/>
</color>
</product>

<product>
<model>型號zzzz</model>   
<name>商品2</name>
<color name="xxx">
<size name="89x28" number="88"/>
<size name="100x28" number="2"/>
</color>
<color name="yyy">
<size name="89x28" number="88"/>
<size name="100x28" number="2"/>
</color>
</product>

<products>

另一種

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

<product>
<name>商品1</name>
<color>xxx</color>
<size>89x28</size>
<number>88</number>
</product>

<product>
<name>B</name>
<color>xxx</color>
<size>89x28</size>
<number>88</number>
</product>

<product>
<name>商品1</name>
<color>xx</color>
<size>86x28</size>
<number>38</number>
</product>

<products>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved