Page 1 of 1

XMLDOM retrieve value from Empty elements

Posted: 16 Aug 2020, 13:44
by majstang
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
}

Re: XMLDOM retrieve value from Empty elements

Posted: 16 Aug 2020, 20:14
by kczx3
That does not appear to be valid XML to me based on my understanding of the “language”.

Re: XMLDOM retrieve value from Empty elements

Posted: 17 Aug 2020, 11:05
by majstang
Yes, you are right! I did gave up that approach and went with something else. Thanks for the help.