XML DOM travers parentnode attributes

Get help with using AutoHotkey and its commands and hotkeys
Posts: 455
Joined: 11 Jan 2014, 04:59

XML DOM travers parentnode attributes

03 May 2017, 16:11


I did find this one trickier than usual when the attributes Im after all are in the parentnode.
How to tackle it?

Code: Select all

kkkkk =
 <root name="DVB-T Europe">
  <group name="Box">
    <channel nr="0" name="SVT1 HD" EPGID="882843412989264" flags="24" ID="3713217920236979536"></channel>
    <channel nr="1" name="SVT2 HD" EPGID="882843412990264" flags="24" ID="3713217920302516536"></channel>
    <channel nr="2" name="TV3" EPGID="882843485342648" flags="25" ID="3713222661988420536"></channel>

  xml := loadXML(kkkkk)
  filenodes := xml.selectNodes("//channels/root/group/channel/@nr")
  GroupName := xml.selectSingleNode("//channels/root/group/@name").text 
  for filenode in filenodes
	 ChannelNr := filenode.text
     x1filenode := filenode.parentNode
	 ChannelName := x1filenode.selectSingleNode("//channels/root/group/channel/@name").text
	 ;ChannelID := x1filenode.selectSingleNode("//channel/@ID").text 
     ;EPGID := x1filenode.selectSingleNode("//channel/@EPGID").text
     ;Flags := x1filenode.selectSingleNode("//channel/@flags").text
     msgbox % "GroupName= " GroupName "`nChannelNr= " ChannelNr "`nChannelName= " ChannelName"`nChannelID= " ChannelID"`nEPGID= " EPGID  "`nFlags= " Flags
  loadXML(ByRef data) {
   o := ComObjCreate("MSXML2.DOMDocument.6.0")
   o.async := false
   o.preserveWhiteSpace := true
   return o

Return to “Ask For Help”

Who is online

Users browsing this forum: boiler, Google [Bot], jvalk87, swagfag and 47 guests