因此,我尝试使用 VB6 中的 SAX 解析(对于古老的 COM 组件)来编辑 xml(输出是 xml)。我更喜欢使用 DOM 解析,但 xml 的大小(可能超过 20MB)迫使我使用 SAX。我对 VB6 比较陌生,并且没有 SAX 解析经验。我在网上浏览过,但即使是我找到的最好的资源(http://www.developerfusion.com/article/84405/sax-and-vb-6/)也让我对如何将 grandchilren 标签与现有属性结合起来知之甚少为重命名的标签创建一个更长的属性。
我有基本的框架设置(如链接网站所示)。我想我也许可以将大部分繁重的工作限制为两个或三个子程序(_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>
你读过像旧文章这样的东西吗SAX 的乐趣:Visual Basic 示例 http://msdn.microsoft.com/en-us/library/ms994312.aspx?
很难告诉你更多。 SAX 实际上非常简单,您只需像处理任何 VB6 表单一样处理它,将其作为状态机即可。这意味着您将编写的大部分逻辑将管理状态,例如在通过事件向您提供转换后的数据时累积和发出转换后的数据。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)