Jump to content

Recommended Posts

Posted

I have been using the XML UDF successfully for sometime. I am now tring to add in error handling for some bad XML files I run into.

$oXmlDoc = _XML_CreateDOMDocument(Default)
    _XML_Load($oXmlDoc,$sFileXML)  ;<== ENTER XML FILE PATH HERE
    If @error Then
;        ConsoleWrite(StringFormat("_XML_load error - @error = %s", @error) & @CRLF)
;        ConsoleWrite("-" & $sFileXML & @CRLF)
        Exit -1
    EndIf
    ConsoleWrite("-" & $sFileXML & @CRLF)

    ;If no specified nodes exist, log error and exit
    If Not _XML_NodeExists($oXmlDoc, "//Property") Then
;        ConsoleWrite("No specified nodes exist" & @CRLF)
        Exit -1
    EndIf

    ;Get number of Property nodes
    $oProperties = _XML_SelectNodes($oXmlDoc,"//Property/Data")
   $iNodeCount = @extended
    $oParents = $oXmlDoc.SelectSingleNode("//Property[@Name='Parents']/Data")

There are no error upto this point. The XML file I am trying to handle has a Data node but when I try to

$sParam = StringSplit($oParents.text, ";")

I get a fatal error (requested action on object failed). How can I test for the problem before I try to do the string split? I tried using @error, and testing $oParents but no luck.

Appreciate any tips.

Posted

Can you provide a short script, with test xml data, that reproduces the error? 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...