我有一个XML文件,我想解析它,但我不知道如何。我们的XML导入工具不理解这一点。此XML有两个选项组,大小和颜色。我想在XML中分离这些组 有可能吗?
我已经尝试了两天没有成功。我的XML文件代码如下。
像这样的XML示例:
<?xml version="1.0" encoding="UTF-8" ?>
<Products>
<Product>
<ProductID>430</ProductID>
<Barcode>78pyg</Barcode>
<ProductName>Sony VAIO</ProductName>
<ProductDesc><![CDATA[Unprecedented power. The next generation of processing technology has arrived. Built into the newest VAIO notebooks lies Intel's latest, most powerful innovation yet]]></ProductDesc>
<CategoryName><![CDATA[main:sub]]></CategoryName>
<Price>10.21</Price>
<options>
<grup_name><![CDATA[Color]]></grup_name>
<values>
<option>
<option_name><![CDATA[White]]></option_name>
<option_value>1000</option_value>
</option>
<option>
<option_name><![CDATA[Black]]></option_name>
<option_value>1000</option_value>
</option>
</values>
<grup_name><![CDATA[Size]]></grup_name>
<values>
<option>
<option_name><![CDATA[S]]></option_name>
<option_value>1000</option_value>
</option>
<option>
<option_name><![CDATA[M]]></option_name>
<option_value>1000</option_value>
</option>
</values>
</options>
<Stock>1000</Stock>
</Product>
</Products>
这就是所需输出的样子:
<?xml version="1.0" encoding="UTF-8" ?>
<Products>
<Product>
<ProductID>430</ProductID>
<Barcode>78pyg</Barcode>
<ProductName>Sony VAIO</ProductName>
<ProductDesc><![CDATA[Unprecedented power. The next generation of processing technology has arrived. Built into the newest VAIO notebooks lies Intel's latest, most powerful innovation yet]]></ProductDesc>
<CategoryName><![CDATA[main:sub]]></CategoryName>
<Price>10.21</Price>
<colors_options>
<color_grup><![CDATA[Color]]></color_grup>
<values>
<option>
<option_name><![CDATA[White]]></option_name>
<option_value>1000</option_value>
</option>
<option>
<option_name><![CDATA[Black]]></option_name>
<option_value>1000</option_value>
</option>
</values>
</colors_options>
<size_options>
<grup_name><![CDATA[Size]]></grup_name>
<values>
<option>
<option_name><![CDATA[S]]></option_name>
<option_value>1000</option_value>
</option>
<option>
<option_name><![CDATA[M]]></option_name>
<option_value>1000</option_value>
</option>
</values>
</size_options>
<Stock>1000</Stock>
</Product>
</Products>
如何使用分隔选项XML文件进行更改?