Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying XML with VBScript

Status
Not open for further replies.

wilted

IS-IT--Management
Jun 30, 2009
2
IE
Afternoon folks, I need some help with modifying xml via vbscript. After a week of googling and head scratchin i'm still none the wise. Basically i need something to change the attributes of a node.
Along the lines of

<Node1>
<Node2>
<Node3 attr1="Something" attr2="SomethingElse">
</Node1>
</Node2>
</Node3>

The attributes might be different time which is where i'm running into problems. Any help would be much appreciated.

Thanks,

W
 
....
Private Function updateNamedItem(ByVal strAttribute, ByRef oNode, ByVal strValue, ByRef xmlDoc)
updateNamedItem = False

Dim oTemp
Set oTemp = oNode.Attributes.getNamedItem(strAttribute)
If Not oTemp Is Nothing Then
oNode.Attributes.getNamedItem(strAttribute).Text = strValue
Else

Dim objAttribute
Set objAttribute = xmlDoc.createAttribute(strAttribute)
objAttribute.Text = strValue
oNode.Attributes.setNamedItem objAttribute
End If
Set oTemp = Nothing

End Function
 
Top Notch Mrmovie you sir are a legend.
Thanks for the tips phv they where most helpful.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top