【发布时间】:2020-01-29 20:23:12
【问题描述】:
我有 XML 有 5 个供应商,我想把这个大文件分成 2 个供应商,每个文件的起始标签是 ,结束标签是 像这样我有 5 个供应商...
如果文件很大,我会写几篇文章,使用 StaX 解析器我的文件是 (>6GB),那么我如何将我的示例文件拆分为多个文件。 .
这是我的示例 XML 文件.....
<?xml version="1.0" encoding="UTF-8"?>
<Shop xmlns="http://www.shpAddress.com">
<tab:Product xmlns:tab="http://www.productName.com">
<tab:Suppllier>
<col:Items xmlns:col="http://www.Items.com">
<col:Delivery>
<Prize xsi:nil="true" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<LastModifiedDate xmlns="">2020-01-28</LastModifiedDate>
</col:Delivery>
</col:Items>
</tab:Suppllier>
<tab:Suppllier>
<col:Items xmlns:col="http://www.Items.com">
<col:Delivery>
<Prize xsi:nil="true" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<LastModifiedDate xmlns="">2021-02-28</LastModifiedDate>
</col:Delivery>
</col:Items>
</tab:Suppllier>
<tab:Suppllier>
<col:Items xmlns:col="http://www.Items.com">
<col:Delivery>
<Prize xsi:nil="true" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<LastModifiedDate xmlns="">2022-02-28</LastModifiedDate>
</col:Delivery>
</col:Items>
</tab:Suppllier>
<tab:Suppllier>
<col:Items xmlns:col="http://www.Items.com">
<col:Delivery>
<Prize xsi:nil="true" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<LastModifiedDate xmlns="">2023-03-28</LastModifiedDate>
</col:Delivery>
</col:Items>
</tab:Suppllier>
<tab:Suppllier>
<col:Items xmlns:col="http://www.Items.com">
<col:Delivery>
<Prize xsi:nil="true" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<LastModifiedDate xmlns="">2024-04-28+05:30</LastModifiedDate>
</col:Delivery>
</col:Items>
</tab:Suppllier>
</tab:Product>
</Shop>
【问题讨论】:
-
实际上就是读取文件,写入文件。每当遇到两个
标签时,关闭写入文件中所有剩余的标签并重新打开一个新文件。 -
请展示您的最大努力,以便我们了解您遇到的问题。在不知道哪里遇到问题的情况下很难为您提供帮助(没有为您编写代码,我们很少有人有时间这样做)