Sets some attribute=value in an XML document for a given tag/XPath
xmlSetValues(xpath, attributes_values) xmlSetValues(xpath, attributes_values, doc)
a string: XPath request pointing to the chosen tag in the XML document.
a 2xN matrix of strings: the (attribute,value) pairs to set.
mlist typed XMLDoc: the XML document in which to write values.
By default, it is the main Scilab preferences file
(SCIHOME + '/XConfiguration.xml'
).
When no explicit XML document doc
is indicated,
xmlSetValues
opens the main Scilab preferences file
SCIHOME + '/XConfiguration.xml'
, looks for the tag pointed to by
xpath
, updates some of its attributes and related values as
provided by attributes_values
, and closes the file.
xmlSetValues
can also be used on-the-fly on an already open XML
document doc
. In this case, the document is kept open after
leaving xmlSetValues
. This mode is useful when several
tags must be updated in the same document.
Attributes to update must already exist for the given tag.
xmlSetValues
is not able to create new ones.
All valid XPath requests are possible. For example to write the XPath request to set proxy settings in the main Scilab configuration file:
Opens SCIHOME+'/XConfiguration.xml'
and gets the
nodes names to access to the expected node:
<?xml version="1.0" encoding="utf-8" standalone="no"?> <interface height="600" path="1/" version="0.17" width="800"> <general title="_(General)"> ... </general> <web title="_(Web)"> <body> <web command-browser="" command-mailer="" default-browser="true" default-mailer="true"/> <proxy enabled="false" host="" password="" port="" user=""/> <previous-proxy enabled="false" host="" password="" port="" user=""/> </body> </web> ... </interface>
The path will be "/interface/web/body/proxy"
(or to simplify "//web/body/proxy"
).
![]() | Modifying incorrectly some preferences can alter the Scilab's behaviour. |
// Get the current values prev = xmlGetValues("//web/body/proxy", ["enabled", "host", "port"]); xmlSetValues("//web/body/proxy", ["enabled", "host", "port"; "true", "my.proxy.org", "1234"]); // Ok that's work xmlGetValues("//web/body/proxy", ["enabled", "host", "port"]) // We restore the previous values xmlSetValues("//web/body/proxy", ["enabled", "host", "port" ; prev]); xmlGetValues("//web/body/proxy", ["enabled", "host", "port"]) | ![]() | ![]() |
Version | Description |
6.1.0 | xmlSetValues() introduced, replacing setPreferencesValue(). |