I'm using faqbot's method of finding an xml value (http://www.autohotkey.com/board/topic/8 ... h-a-value/), it works great. Though I'm wondering, can I use a similar method to Update / Add attribute or elements in the actual .xml file (with the built in COM ahk functionality)?
I already asked at Autohotkey.com forums, but I didn't get an answer there. Would greatly appreciate any help
Thank you
-Mikael
Update/Add XML attribute or elements Topic is solved
Re: Update/Add XML attribute or elements Topic is solved
Code: Select all
xml_doc =
(
<root>
<child_1 some_attrib="some value">Node Text</child_1>
</root>
)
xml := ComObjCreate("MSXML2.DOMDocument")
xml.setProperty("SelectionLanguage", "XPath") ;// for XP and below
xml.async := false
xml.loadXML(xml_doc)
;// setting / getting attribute(s)
child1 := xml.selectSingleNode("/root/child_1") ;// select the 'child_1' node
child1.setAttribute("some_attrib", "new value") ;// set attribute value
MsgBox % child1.getAttribute("some_attrib") ;// get attribute value
;// creating and appending an element
child_2 := xml.createElement("child_2")
child_2.text := "Some text" ;// set text
xml.documentElement.appendChild(child_2) ;// append to 'root' node
MsgBox % xml.xml ;// show XML representtation of document
return
Re: Update/Add XML attribute or elements
Thank you, very useful