Forum Discussion

YYF's avatar
YYF
New Contributor
4 years ago
Solved

Not able to find the nodes object when tried to read xml file

Hello all, I try to read a xml file. I get the DOM Doc object, but I can't get node or nodes list by using any method or property. Here is the code:

def GetDomDocFromXML(fileLocation):
    domObj = Sys.OleObject["Msxml2.DOMDocument.6.0"]
    domObj.setProperty("ProhibitDTD",False)
    domObj.async = False
    domObj.load(fileLocation)
# Report an error, if, for instance, the markup or file structure is invalid
    if domObj.parseError.errorCode != 0:
        s = "Reason:\t" + Doc.parseError.reason + "\n" + "Line:\t" + aqConvert.VarToStr(Doc.parseError.line) + "\n" + "Pos:\t" + aqConvert.VarToStr(Doc.parseError.linePos) + "\n" + "Source:\t" + Doc.parseError.srcText

# Post an error to the log and exit
        Log.Error("Cannot parse the document.", s)
    else:
        return domObj

 

def CheckCytovilleModeTableFile():
    dict = {}
    path = PathPrefix + "FluidicsdModeTable\\CytovilleModeTable.xml"
    doc = GetDomDocFromXML(path)
    rootNode = doc.documentElement
    nodes = rootNode.childNodes

 

I've tried selectSingleNodegetElementsByTagName, none of them work.

Log picture is in attach file.

 

  • I combine these two function together. The problem is fixed, but I don't know why.

1 Reply

  • YYF's avatar
    YYF
    New Contributor

    I combine these two function together. The problem is fixed, but I don't know why.