Announcement

Collapse
No announcement yet.

XML.GetValue returns error for not existing elements

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML.GetValue returns error for not existing elements

    I need to get a value from an XML where the element might not exist within the XML (i.e. it is an optional element).

    The function XML.GetValue returns an empty string in this case, which is fine, because I can check it and react accordingly. Nevertheless there is an error-entry in the log-file.

    How could I avoid the error in the log-file? (It does not harm the program flow, but it is at least confusing, because in my case this is not an error situation but a regular use case.)

    With best regards

    Burkhard

  • #2
    The error is expected, when you use XML.GetValue() and the value does not exist. If you must avoid the error in the log, then you could create a custom function which returns a boolean, named, for example, XML.DoesValueExist(), and call it before XML.GetValue(). This custom function could use XML.GetElementNames() to list all the child elements, and then you can search among the siblings for the one you wish to extract the value for. If it exists, return true, otherwise false - so XML.GetValue() will be skipped.

    Ulrich

    Comment

    Working...
    X