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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for Attribute Names with VBscript

Status
Not open for further replies.

oakguy

Technical User
Mar 5, 2007
2
US
I need to create about 500 new xml files from old ones for a new .net client. I can use vbscript to open the old xml files but I'm having trouble parsing through the file to find the right attributes. The xml files are client created configuration files therefore, the client reads them well. I have tried the following to open the files and read the attributes:

Dim Root
set objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = "false"
objXML.load("c:\Client Settings\ClientSettings_User.Name.xml")
Set root = objXml.documentElement
Set elm = objXml.getElementsByTagName("phonelistnotebooklastknownadminselected")



I' am only retrieving parent tags and not the child tags I'm looking for. I want retrieve the x number of multi values below for different directories to import to a new .net xml client file. Any ideas? thanks for any help.

<I3_XML_VALUE name="phonelistnotebooklastknownadminselected" display-name="PhoneListNotebookLastKnownAdminSelected" type="7">

<I3_XML_VALUE name="multi" val="15002|Outlook Contacts|Outlook Contacts" />
<I3_XML_VALUE name="multi" val="15002|IC Private Contacts|IC Private Contacts" />
<I3_XML_VALUE name="multi" val="15002|IC Public Contacts|IC Public Contacts" />
<I3_XML_VALUE name="multi" val="15000|Company Directory|Company Directory" />
 
First, welcome to Tek-Tips.

Creating "new xml files from old ones" would seem to be a job for XSLT. Can you describe the transformation process? If so, then I would think you would want to develop an XSLT transform that you could apply, rather than create a bunch of VBScript.

Tom Morrison
 
The parent and its children of the same tag name I3_XML_VALUE?!!

In any case, unless and unlikely you use archaic core service, you can use xpath.
[tt]
set elm=objXml.selectNodes("//I3_XML_VALUE[@name='phonelistnotebooklastknownadminselected']/I3_XML_VALUE")
for each obj in elm
sval=obj.getAttribute("val") 'the desire value for each child I3_XML_VALUE
'do things about sval such as splitting it etc etc...
next
[/tt]
Get the idea?
 
Yes. I see that works. Very cool!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top