XML parser based on MSXML.DOMDocument not working

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
ic2
Posts: 1856
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

XML parser based on MSXML.DOMDocument not working

Post by ic2 »

I used the below simple XML parser in VO earlier but I discovered an issue I didn't know before. You can pass a node and a string and if any isn't found it hits the errorblock, which means that just passing a tag would work because after hitting the error condition it will just look up the first available tag without an issue.

However, despite debug showed that both a node and tag were found I noticed that it disregarded the node and simply returned the 1st tag found despite the node passed should have returned the second. It also is case dependent which appeared an issue too.

Does anybody have an idea why it doesn't work (See below), or if there's a better XMLParser? Note that it should also take into account an XML reply containing ![CDATA ; this does work fine here.

In case you want to recommend a .Net XML parser: we need it from a VO program and adding .Net code will keep us occupied too much with Side By Side errors so no X#/C# code in this project I am afraid.

I can fix it temporarily with AT3 etc as I know what I can expect in the XML but it's not ideal so any suggestions are welcome.

Dick



FUNCTION XMLParser(cFile AS STRING,cNode AS STRING,cTag AS STRING) AS STRING
LOCAL oXML AS OBJECT

LOCAL oXMLNodeObj AS OBJECT
LOCAL cResult AS STRING
LOCAL cbOldErrorBlock AS CODEBLOCK

oXML := OLEAutoObject{"MSXML.DOMDocument"} // Instantiate the parser

IF !oXML:fInit
ErrorBox{,"Can't open XMLDOM "}:show()
RETURN ""
ENDIF
oXML:Async:=.f.

oXML:load(cFile)
BEGIN SEQUENCE
cbOldErrorBlock:=ErrorBlock()
ErrorBlock({|X|DummyFunction(X)})
oXMLNodeObj:=oXML:documentElement:selectNodes(cNode)
cResult:=oXML:GetElementsByTagName(cTag):item(0):NodeTypedValue
RECOVER
END
ErrorBlock(cbOldErrorBlock)
Post Reply