Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - English


xmlSetValues

Sets some attribute=value in an XML document for a given tag/XPath

Syntax

xmlSetValues(xpath, attributes_values)
xmlSetValues(xpath, attributes_values, doc)

Arguments

xpath

a string: XPath request pointing to the chosen tag in the XML document.

attributes_values

a 2xN matrix of strings: the (attribute,value) pairs to set.

doc

mlist typed XMLDoc: the XML document in which to write values. By default, it is the main Scilab preferences file (SCIHOME + '/XConfiguration.xml').

Description

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.

Examples

// 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"])

See also

  • xmlGetValues — Parses and gets values of chosen tags attributes in a XML file

History

VersionDescription
6.1.0 xmlSetValues() introduced, replacing setPreferencesValue().
Report an issue
<< xmlSetAttributes XML Management xmlValidate >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:13:09 CEST 2024