Skip to main content.

#edit-config-xpath capability

#edit-config-xpath capabilities modifies the behavior of the edit-config operation. It allows the use of XPath to address the nodes on which an operation will be done. This capability adds new attributes to the config element:

The use of namespaces considerably limit the scope of an XPath request. Therefore, it avoids to query the whole configuration and improves performances. The following syntax is inspired from http://www.ietf.org/internet-drafts/draft-urpalainen-simple-xml-patch-ops-01.txt

Creating a new XML element

This operation appends the given node as a child of all the nodes selected by the "sel" XPath expression. In the example, it will create a user under the users element(s).

<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config type="xpath" xmlns:rr="my:own:namespace:root:elements" xmlns:uu="my:own:namespace:users" operation="create" sel="/rr:top/uu:users">
      <user xmlns="my:own:namespace:users">
        <name>Alice</name>
        <login>alicefoo</login>
      </user>
    </config>
  </edit-config>
</rpc>

Deleting an XML element

The "delete" operation deletes all the nodes selected by the "sel" XPath expression. When the operation attribute is set to "delete", "config" must not have children. In the example, it will delete all the users.

<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config type="xpath" xmlns:rr="my:own:namespace:root:elements" xmlns:uu="my:own:namespace:users" operation="delete" sel="/rr:top/uu:users/uu:user">
    </config>
  </edit-config>
</rpc>

Replacing an existing XML element

The "replace" operation replaces all the selected nodes with the given node. In the example, it replace the user which name is 'Alice' with a new user having the same name.

<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config type="xpath" xmlns:rr="my:own:namespace:root:elements" xmlns:uu="my:own:namespace:users" operation="replace" sel="/rr:top/uu:users/uu:user[uu:name='Alice']">
      <user xmlns="my:own:namespace:users">
        <name>Alice</name>
        <login>alicefoo</login>
        <building>a2</building>
        <room>100</room>
      </user>
    </config>
  </edit-config>
</rpc>