【发布时间】:2011-08-27 13:07:41
【问题描述】:
所以我试图在 VB6 中使用 SAX 解析来编辑一个 xml(输出是一个 xml)(对于一个古老的 COM 组件)。我更喜欢使用 DOM 解析,但 xml 的大小(可能超过 20MB)迫使我使用 SAX。我对 VB6 比较陌生,而且我在 SAX 解析方面没有经验。我在网上环顾四周,但即使是我找到的最好的资源 (http://www.developerfusion.com/article/84405/sax-and-vb-6/) 也让我对如何将孙子标签与现有属性结合起来知之甚少为重命名的标签创建一个更长的属性。
我有基本的框架设置(如链接网站所示)。我想我可能可以将大部分繁重的工作限制在两个或三个子过程中(_startDocument 中的前四行,使用 _startElement 获取描述标记,使用 endElement 将描述放入函数标记中)。然而,我缺乏 VB6/SAX 知识真的让我很伤心。任何帮助将不胜感激。
这是 XML 现在的样子;
<errordetails>
<error desc=”Count: 2”/>
<error desc=”System: System X”/>
<error desc=”Reason: Reason X”/>
<functions>
<function name=”x1” Description=”y1”>
<violations count="2">
<violation><source>admin</source><description>the first reason</description></violation>
<violation><source>admin</source><description>the second reason</description></violation>
</violations>
</function>
<function name=”x2” Description=”y2”>
<violations count="1">
<violation><source>admin</source><description>another reason</description></violation>
</violations>
</function>
</functions>
</errordetails>
这是我希望 xml 的样子;
<errordetails>
<error desc=”Count: 2”/>
<error desc=”System: System X”/>
<error desc=”Reason: Reason X”/>
<error desc=”FunctionName: x1, FunctionDescription: y1, FunctionReason: the first reason, FunctionReason: the second reason”/>
<error desc=”FunctionName: x2, FunctionDescription: y2, FunctionReason: another reason"/>
</errordetails>
【问题讨论】: