VB6 Insert nodes and set multiple attributes



I need to insert nodes into an XML file. Three things make this complex: 1. The node names are the same as other node names. 2. The node names have 3 attributes. 3. The nodes have to be inserted at a specific location.


Only the combination of the node name and its three attributes make them unique. My task is to insert the following:



<Markers Version="1">
<Marker Version="1" Index="0">
<Second ObjectRef="23"/>
<First>5009119315200</First>
</Marker>
<Marker Version="1" Index="1">
<Second ObjectRef="24"/>
<First>419274305049600</First>
</Marker>
</Markers>


Into this:


[insert it here]



<Node Version="1"/>


================================================================================== I then need to insert the follow right after the above: comment abc 8475667200 5009119315200 chapter 00;00;19;21 name ThisIsAChapterMarkerFlag


And also:


comments last chapter 8475667200 419274305049600 chapter 00;27;30;18 name ThisIsAChapterMarkerFlag


As you can see nodes named "Marker" and "Markers" have three attributes. I am attempting to read the attribute names and values in an attempt to know how to set them. I have seen many answers but none work. In the end, I just need to: 1. Create the nodes at the right place. 2. Set the attributes, all three.


In an attempt to read the attribute names and values I: 1. create a node list. 2. Use Msgbox: NodeList.item(1 through N).Attributes.Item(0).Text NodeList.item(1 through N).Attributes.Item(0).Basename NodeList.item(1 through N).Attributes.Item(0).nodeTypedValue NodeList.item(1 through N).Attributes.Item(0).NodeValue NodeList.item(1 through N).Attributes.Item(0).nodeTypeString


Running this produces the attribute names "ObjectID", "Version" and their values (in different message boxes), but not the attribute, "ClassID" or its values. I have tride setting .attributes.item(1).Text / BaseName etc.. but I get: "Object Variable or With Block variable not set"


If I try the IF not NodeList.item(1 through N).Attributes.Item(0).Text is Nothing I get:


Type Mismatch


I am desperate at this point. The answer is a function greatly needed. Thanks


No comments:

Post a Comment