XML File input

Get help with using AutoHotkey and its commands and hotkeys
dgoudie
Posts: 1
Joined: 24 Mar 2017, 11:25

XML File input

24 Mar 2017, 13:59

Hi!

I know that there have been a number of topic discussing reading of XML data, but I haven't had any luck with the format of the XML that I'm working with. A portion of the XML looks like this ->

Code: Select all

<?xml version="1.0"?>
<Machines>
  <Computer Name="computer1" OS="Windows 7 32-bit" MAC="xxxxxxxxxxxx" Notes="VSCODE" />
  <Computer Name="computer2" OS="Windows 7 32-bit" MAC="yyyyyyyyyyyyyy" Notes="NOTEPAD++" />
</Machines>
I'm trying to retrieve the "Notes" if given the computer name. Any help would be appreciated!

please do not duplicate posts: tlm
TravisQ
Posts: 15
Joined: 17 May 2015, 23:51

Re: XML File input

24 Mar 2017, 15:49

Code: Select all

xml=
(
<Machines>
  <Computer Name="computer1" OS="Windows 7 32-bit" MAC="xxxxxxxxxxxx" Notes="VSCODE" />
  <Computer Name="computer2" OS="Windows 7 32-bit" MAC="yyyyyyyyyyyyyy" Notes="NOTEPAD++" />
</Machines>
)

name:="computer1"

xmlDoc := ComObjCreate("MSXML2.DOMDocument.6.0")
xmldoc.loadXML(xml) ;xmldoc.load("xml.xml")
if (xmlDoc.parseError.errorCode != 0) 
MsgBox,% xmlDoc.parseError.reason
else {
notes:=xmldoc.selectSingleNode("//Machines//Computer[@Name='" name "']/@Notes")
	MsgBox,% notes.xml " - " notes.Text
}
NoteList := xmldoc.selectnodes("//Machines//Computer/@Notes")
	for item in NoteList
	MsgBox,% item.xml " - " item.Text

Return to “Ask For Help”

Who is online

Users browsing this forum: deten, Getfree, Google [Bot], Odlanir and 144 guests