getPreferencesValue() can't read a tag having multiple occurrences. +: the pathfile is not accepted instead of the XML handle of the document
Reported by Samuel GOUGEON (@sgougeon)
BUG DESCRIPTION:
----------------
getPreferencesValue() is limited in 2 aspects impeding easy or further developpments:
* It is not possible to get the values of some attributes for a tag having multiple occurrences in the targeted file.
Example:
--> scinotesFile = SCIHOME + "/scinotesConfiguration.xml";
--> doc = xmlRead(scinotesFile);
--> recent = getPreferencesValue("//Setting/Profile/recentFiles/document", "path", doc);
!--error 10000
getPreferencesValue: Invalid XPath request.
at line 39 of function getPreferencesValue called by :
recent = getPreferencesValue("//Setting/Profile/recentFiles/document", "path", doc);
* When we need to run only one query on a given file, it is not possible to directly provide the path+filename.
We still need to open and close the XML source in an external way.
It is not very handy, and it is then quite easy to forget closing the source, noticeably whether
an error occurs when parsing the file.
Example:
-->recent = getPreferencesValue("//Setting/Profile/recentFiles/document", "path", scinotesFile);
!--error 10000
getPreferencesValue: Wrong type for input argument #3: A XMLDoc expected.
at line 23 of function getPreferencesValue called by :
recent = getPreferencesValue("//Setting/Profile/recentFiles/document", "path", scinotesFile);
ERROR LOG:
----------
See examples hereabove.
HOW TO REPRODUCE THE BUG:
-------------------------
scinotesFile = SCIHOME + "/scinotesConfiguration.xml";
tag = "//Setting/Profile/recentFiles/document";
recent = getPreferencesValue(tag, "path", scinotesFile);