简体   繁体   English

VB6 XML插入节点并设置属性

[英]VB6 XML insert nodes and set attributes

I need to insert nodes into an existing xml file. 我需要将节点插入到现有的xml文件中。 This operation will create what has to be done manually. 此操作将创建必须手动执行的操作。 This particular xml file has attributes (as seen using my XML viewer) for some of the nodes. 这个特定的xml文件具有某些节点的属性(如使用我的XML查看器所看到的)。 Some have as many as 3 attributes. 有些具有多达3个属性。 They are named ObjectId, ClassId and Version. 它们分别命名为ObjectId,ClassId和Version。

I can't seem to figure out how to insert these nodes with these attributes. 我似乎无法弄清楚如何使用这些属性插入这些节点。 Below is a sample of what needs to be inserted: 以下是需要插入的示例:

<Markers ObjectID="22" ClassID="bee50706-b524-416c-9f03-b596ce5f6866" Version="2">
    <Markers Version="1">
        <Marker Version="1" Index="0">
            <Second ObjectRef="23"/>
            <First>0</First>
        </Marker>
        <Marker Version="1" Index="1">
            <Second ObjectRef="24"/>
            <First>8475667200</First>
        </Marker>
        <Marker Version="1" Index="2">
            <Second ObjectRef="25"/>
            <First>254270016000</First>
        </Marker>
        <Marker Version="1" Index="3">
            <Second ObjectRef="26"/>
            <First>72051646867200</First>
        </Marker>
        <Marker Version="1" Index="4">
            <Second ObjectRef="27"/>
            <First>471925149696000</First>
        </Marker>
    </Markers>
    <Node Version="1"/>
</Markers>

This represents 4 markers in a video timeline. 这代表了视频时间轴中的4个标记。 The above is only a reference to additional nodes that need to be created. 以上只是对需要创建的其他节点的参考。 If I can see how to add these, I believe I can do the rest. 如果我能看到如何添加这些内容,我相信我可以做剩下的事情。

Are these attribute names just arbitrary names or is object ID, Class ID and Version specific node attribute types? 这些属性名称是任意名称还是对象ID,类ID和版本特定的节点属性类型?

Your help will make a very tedious process easy / simple. 您的帮助将使一个非常繁琐的过程变得容易/简单。 Thanks 谢谢

The attribute names of ObjectID, ClassID and Version are specific to the application that is using this file, but they are not specific to XML itself. ObjectID,ClassID和Version的属性名称特定于使用此文件的应用程序 ,但并不特定于XML本身。

It's very easy to work with XML in .NET, but a little harder in VB6. 在.NET中使用XML非常容易,但是在VB6中则有点困难。 Still, you're not out of luck. 不过,您并非没有运气。 I would look at the top answer to this question , which provides guidance on how to work with XML in VB6. 我将看这个问题的最高答案,它为如何在VB6中使用XML提供了指导。

If that doesn't work for you, you can work with the file as if it were just a text file and make sure that you use the name attributes and tag names (remember: XML is case-sensitive!). 如果那不适合您,则可以像对待纯文本文件一样使用该文件,并确保使用名称属性和标记名(请记住:XML区分大小写!)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM