Skip to content

Function: x() ​

ts
function x(
   name, 
   attrsOrChild?, 
   ...children
): XmlElement;

Defined in: netconf/src/xml/builder.ts:46

XML element builder, hyperscript-style (like h() in Preact and Vue): the name, optional attributes, then children. The one-letter name keeps nested request bodies readable; import it under another name if you prefer, e.g. import { x as xmlEl } from '@node-net/netconf'.

ts
const IF_NS = 'urn:ietf:params:xml:ns:yang:ietf-interfaces';
x('get-config', { xmlns: NETCONF_NS },
  x('source', x('running')),
  x('filter', { type: 'subtree' }, x('interfaces', { xmlns: IF_NS })))

Elements without an xmlns inherit the default namespace in scope when serialised.

Parameters ​

name ​

string

attrsOrChild? ​

| Readonly<Record<string, AttrValue>> | Child

children ​

...Child[]

Returns ​

XmlElement

Released under the MIT Licence.