snippets

Check-in [ea9356c3c9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:tdom nodecmd examples
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ea9356c3c9b047272d5d08c6e82c7c56aaca7304c388c8bd96a31fb1d9c79057
User & Date: alex 2018-08-15 14:03:16
Context
2018-08-31
11:47
add tcl2json with array check-in: 29d3bcec1f user: alex tags: trunk
2018-08-15
14:03
tdom nodecmd examples check-in: ea9356c3c9 user: alex tags: trunk
13:19
added some old dde snippets from Jun 2007 check-in: c9723faeb5 user: alex tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added tdom/tdom-nodecmd-1.tcl.

























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
#\
exec tclsh8.6 "$0" "$@"

package require tdom

dom createNodeCmd elementNode a
dom createNodeCmd elementNode b
dom createNodeCmd elementNode c
dom createNodeCmd textNode t

set doc [dom createDocument root]
set root [$doc documentElement]

proc c_node {args} {
  c {*}$args {t "some text"}
}

$root appendFromScript {
  a v 1 {
    b {
      t text
    }
  }
  c_node a 1 b 2
}

puts [[$doc documentElement] asXML -indent 2]

Added tdom/tdom-nodecmd-2.tcl.





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
#\
exec tclsh8.6 "$0" "$@"

package require tdom

dom createNodeCmd elementNode a
dom createNodeCmd elementNode b
dom createNodeCmd textNode t

set doc [dom createDocument root]
set root [$doc documentElement]

proc c_node {args} {
  dom createNodeCmd elementNode c
  c {*}$args {t "some text"}
}

$root appendFromScript {
  a v 1 {
    b {
      t text
    }
  }
  #c
  c_node a 1 b 2
  c_node c 3
}

puts [[$doc documentElement] asXML -indent 2]

Added tdom/tdom-nodecmd-3.tcl.





















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
#\
exec tclsh8.6 "$0" "$@"

package require tdom

dom createNodeCmd elementNode a
dom createNodeCmd elementNode b
dom createNodeCmd elementNode c
dom createNodeCmd elementNode d
dom createNodeCmd elementNode e
dom createNodeCmd textNode t

set doc [dom createDocument root]
set root [$doc documentElement]

$root appendFromScript {
  a v 1 {
    b {
      t text
    }
    c {}
  }
}

set nodeC [$root selectNodes {/root/a/c}]

$nodeC appendFromScript {
  d v 1 {
    t appendFromScript
  }
}

set nodeD [$root selectNodes {/root/a/c/d}]

$nodeC insertBeforeFromScript {
  e {
    t insertBeforeFromScript
  }
} $nodeD

puts [[$doc documentElement] asXML -indent 2]