Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


How to set attributes / add children with duplicate node names

How to set attributes / add children with duplicate node names

How to set attributes / add children with duplicate node names

I need to add children and set the attribute for a node where it is the second instance in a family of nodes.
But I cant seem to find a way to "SelectSingleNode" so that I can add children and set attributes.
This is what I have created so far:

<Markers ObjectID="22" ClassID="bee50706-b524-416c-9f03-b596ce5f6866" Version="2">
<Markers Version="1" ObjectRef="24">
<Marker Version="1" Index="0">
<Second ObjectRef="23"/>
<Node Version="1"/>

I cant get any further because I cant set the attribute of the second instance of the node "Marker". Everything I try sets the first instance of "Marker" and replaces what it already has.

This is what I need to end up with:

<Markers ObjectID="22" ClassID="bee50706-b524-416c-9f03-b596ce5f6866" Version="2">
<Markers Version="1">
<Marker Version="1" Index="0">
<Second ObjectRef="23"/>
<Marker Version="1" Index="1">
<Second ObjectRef="24"/>
<Node Version="1"/>

A nodelist of "//Markers[@ObjectID='22'/Markers/Marker) produces 2 items in the list.
I am trying to figure out how to reference a single node from this list but I just cant figure out how.

Is there a way to identify a node that has no attributes???
Thanks for your help

RE: How to set attributes / add children with duplicate node names

Are you sure this is a VB6 question?

RE: How to set attributes / add children with duplicate node names

It looks like an MSXML DOM question and not a VB6 question.

An MSXML NodeList is pretty well documented, see IXMLDOMNodeList Members. There are few VB6 examples but the VBScript examples (while shabby) should be correct even if not always of high quality.

If this is indeed VB6 then I'd have thought the IDE's Object Browser would have provided 98% of what you need to understand to use one anyway. Possibly leaving you to guess or experiment whether you have 0-based or 1-based item indexes in MSXML if you didn't know from prior experience.

Short answer: Use the .item() method and pass it a 0-based index, or iterate from 0 to .length - 1 if you want to visit each Node in the NodeList.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close