XMLDOM retrieve value from Empty elements

Get help with using AutoHotkey and its commands and hotkeys
majstang
Posts: 89
Joined: 11 Feb 2018, 03:39

XMLDOM retrieve value from Empty elements

16 Aug 2020, 13:44

I have a strange XML doc, which apparently is according to xml standard. Samples below. How should I handle so called empty elements, which means they do not have any close tags? It is impossible to retrieve the file path and stream number from them. Anyone knows how?

Code: Select all

/* ; Working sample according to usual xml standard
UTF=
(
<Version>
  <File>C:\file.exe</File>
  <Stream>1059</Stream>	
</Version>
)
xx1 := loadXML(UTF)
MSGBOX % xx1.selectSingleNode("Version/File").text "`n" xx1.selectSingleNode("Version/Stream").text
*/

UTF= ; Non working sample with empty elements
(
<Version>1
<File>C:\file.exe
<Stream>1059
)
xx1 := loadXML(UTF)
MSGBOX % xx1.selectSingleNode("File").text "`n" xx1.selectSingleNode("Version/Stream").text

loadXML(ByRef data) {
   o := ComObjCreate("MSXML2.DOMDocument.6.0")
   o.async := false
   o.preserveWhiteSpace := true
   o.loadXML(data)
   return o
}
User avatar
kczx3
Posts: 1195
Joined: 06 Oct 2015, 21:39

Re: XMLDOM retrieve value from Empty elements

16 Aug 2020, 20:14

That does not appear to be valid XML to me based on my understanding of the “language”.
majstang
Posts: 89
Joined: 11 Feb 2018, 03:39

Re: XMLDOM retrieve value from Empty elements

17 Aug 2020, 11:05

Yes, you are right! I did gave up that approach and went with something else. Thanks for the help.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, BeSu, Bing [Bot], DaveT1, mikeyww, pizzapizze, Saarthak Kamra, sachin24 and 51 guests