Failed to insert code in manual sample to access tree data information.

An error was generated when I changed the writing.tcl in the cmas2d_customelib problem type by inserting the sample lines of code given in the manual.

The following code is given in the customisation manual (page 42; in the “Accessing tree data information” section).
I inserted it into the writing.tcl code of the cmas2d_customlib problem type, just before the “customlib::EndWriteFile” line.

    (writing.tcl code; many lines omitted!)
    customlib::WriteString "Node   Mass [gid_groups_conds::give_active_unit M]"
    customlib::WriteNodes $condition_list $condition_formats "" active
    
# The following four lines are inserted from the sample code
# found on page42 of the customization manual.
set document [$::gid_groups_conds::doc documentElement]
set xpath {/cmas2d_customlib_data/condition[@n='Point_Weight']/group[@name='Point Weight Auto1']/value[@n='Weight']}
set xml_node [$document selectNodes $xpath]
set value [get_domnode_attribute $xml_node v]

    customlib::EndWriteFile ;#finish writting
}

As shown in the figure, I encountered an error after CntlX-CntlC operation.


What is wrong with me?

Am using GiD 16.0.7 on Windows11 Pro.
writing.tcl.zip (1.17 KB)
foobar.gid.zip (9.49 KB)

It is a mistake of the documentation,
set xpath {/cmas2d_customlib_data/condition[@n=‘Point_Weight’]/group[@name=‘Point Weight Auto1’]/value[@n=‘Weight’]}
set xml_node [$document selectNodes $xpath]
in this case the attribute of the node ‘group’ must be ‘n’, not ‘name’
group[@name=‘Point Weight Auto1’]

group[@n=‘Point Weight Auto1’]
Now we have fixed this documentation:

Then $document selectNodes $xpath was not selecting any DOM node because the wrong xpath

In any case, you can always examine the current DOM to know the xpath with something like
-np- W [[$::gid_groups_conds::doc documentElement] asXML]
and you will see it as XML, this in your model:

<cmas2d_customlib_data version=“1.0”>