WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

XML
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

XML selectNodes Sample

 Keywords: XML selectNodes Manifest MSXML2 MSXML2.DOMDocument.6.0

;<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
;<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
;
;<assemblyIdentity name="happy.exe" version="2000.80.382.0" type="win32" processorArchitecture="x86"/>
;
;<description>Built with: Side-by-Side Manifest Maker (2.7.0.428)</description>
;<description>Copyright: 2004-2005 © Maze Computer Communications, Inc.  All rights reserved.</description>
;<description>License: 5 users license</description>
;
;<dependency>
; <dependentAssembly>
;  <assemblyIdentity name="Common.SharedAssembly" version="3.0.0.0" type="win32" publicKeyToken="c3edcabe9fc73c4b" processorArchitecture="x86"/>
; </dependentAssembly>
;</dependency>
;
;<dependency>
; <dependentAssembly>
;  <assemblyIdentity name="Crystal Reports.Shared Assembly" version="6.1.0.0" type="win32" publicKeyToken="93dd5654945d6517" processorArchitecture="x86"/>
; </dependentAssembly>
;</dependency>
;
;<file name="COMCTL32.OCX">
; <comClass
;     clsid="{0713E8A2-850A-101B-AFC0-4210102A8DA7}"
;     description="Microsoft TreeView Control, version 5.0 (SP2)"
;     tlbid="{6B7E6392-850A-101B-AFC0-4210102A8DA7}"
;     threadingModel="apartment"
;     miscStatusContent="recomposeonresize,cantlinkinside,insideout,activatewhenvisible,setclientsitefirst"
;     progid="COMCTL.TreeCtrl.1">
;    <progid>COMCTL.TreeCtrl</progid>
; </comClass>
;</file>
;</assembly>

xmlfile = "c:\temp\test.xml"

xmlDoc = ObjectCreate("MSXML2.DOMDocument.6.0")
xmlDoc.async = @false;
xmlDoc.load( xmlfile )
XmlDoc.SetProperty('SelectionLanguage','XPath')

assembly_namespace_V1='urn:schemas-microsoft-com:asm.v1';
assembly_namespace_V2='urn:schemas-microsoft-com:asm.v2';
assembly_namespace_V3='urn:schemas-microsoft-com:asm.v3';
ns = 'xmlns:a="':assembly_namespace_V1:'" xmlns:b="':assembly_namespace_V2:'" xmlns:c="':assembly_namespace_V3:'"'
XmlDoc.setProperty('SelectionNamespaces', ns);

If xmlDoc.parseError.errorCode != 0
   Pause('parseError', xmlDoc.parseError.reason)
Else
   Pause('Contents', xmlDoc.documentElement.xml)

   xPath =  "/a:assembly/a:dependency/a:dependentAssembly/a:assemblyIdentity"
   objNodeList = XmlDoc.selectNodes(xPath)
   For n = 0 To objNodeList.Length-1
      objNode = objNodeList.item(n)
      val_version = objNode.attributes.getNamedItem("version").value
      val_name = objNode.attributes.getNamedItem("name").value
      val_processorArchitecture = objNode.attributes.getNamedItem("processorArchitecture").value
      val_type = objNode.attributes.getNamedItem("type").value
      Pause( "Details", "XPATH = ": xPath:@LF:"NODE = ":n:@LF:@LF:val_version:@LF:val_name:@LF:val_processorArchitecture:@LF:val_type)
   Next

   xPath =  "/a:assembly/a:file/a:comClass"
   objNodeList = XmlDoc.selectNodes(xPath)
   For m = 0 To objNodeList.Length-1
      objNode = objNodeList.item(m)
      val_clsid = objNode.attributes.getNamedItem("clsid").value
      val_description = objNode.attributes.getNamedItem("description").value
      val_progid = objNode.attributes.getNamedItem("progid").value
      Pause("Details", "XPATH = ": xPath:@LF:"NODE = ":m:@LF:@LF:val_clsid:@LF:val_description:@LF:val_progid)
   Next

EndIf

objNode = 0
XmlDoc = 0
Exit

Article ID:   W18495
Filename:   XML selectNodes Sample.txt
File Created: 2013:01:03:11:28:04
Last Updated: 2013:01:03:11:28:04