yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Quintiq file version 2.0
#parent: #root
StaticMethod GetNodeOrDefaultValue (XMLDOMElement parentnode, String tagname, String defvalue) as String
{
  #keys: '1[105690.0.479185360]'
  Description: 'Retrieves the value of the node if the node exist or the default value instead if the node does not exist'
  TextBody:
  [*
    // boon kiat Nov-14-2013 (created)
    value := defvalue;
    
    elemssize := parentnode.GetElementsByTagName( tagname ).Size();
    assert( elemssize = 0 or elemssize = 1 , "Expected exactly 0 or 1 element with the tag name '" + tagname + "'; found", elemssize, "instead" );
    
    if( parentnode.GetElementsByTagName( tagname ).Size() > 0 )
    {
      value := parentnode.GetElementByTagName( tagname, 0 ).TextContent();
    }
    
    return value;
  *]
}