Leser: 2
7 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<opt>
<system_1>
<forms name="main_menu">
...
</forms>
<forms name="disconnect">
...
</forms>
...
</system_1>
<system_2>
<forms name="whatever">
...
</forms>
...
</system_2>
</opt>
1
2
3
4
5
6
7
my $xs = new XML::Simple();
my $tree = $xs->XMLin('vxml_tree.xml');
my $vxml = $tree->{system_1};
foreach my $form (sort keys %{$vxml->{forms}})
{
...
}
foreach my $form (sort keys %{$vxml})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<opt>
<system_1 name="forms">
<main_menu>
...
</main_menu>
<disconnect>
...
</disconnect>
</system_1>
<system_2 name="forms">
<whatever>
...
</whatever>
</system_2>
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
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
my @forms = qw(first second third);
my $tree;
my $vxml;
my $filename = 'vxml_tree.xml';
$vxml->{forms}->{$_} = ['dummy', { more_dummy => 'more' }] for (@forms);
$tree->{system_1} = $vxml;
print Dumper $tree;
my $xs = new XML::Simple();
my $xml = $xs->XMLout($tree);
open my $fh, '>', $filename or die $!;
print $fh $xml;
close $fh;
$tree = $xs->XMLin($filename);
print Dumper $tree;
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
43
44
45
46
47
$VAR1 = {
'system_1' => {
'forms' => {
'first' => [
'dummy',
{
'more_dummy' => 'more'
}
],
'second' => [
'dummy',
{
'more_dummy' => 'more'
}
],
'third' => [
'dummy',
{
'more_dummy' => 'more'
}
]
}
}
};
$VAR1 = {
'system_1' => {
'first' => [
'dummy',
{
'more_dummy' => 'more'
}
],
'second' => [
'dummy',
{
'more_dummy' => 'more'
}
],
'third' => [
'dummy',
{
'more_dummy' => 'more'
}
],
'name' => 'forms'
}
};
my $xs = new XML::Simple(ForceArray => 1);
my $xml = $xs->XMLout($tree, NoAttr => 1);
print qq($_\n) for keys %{$tree->{system_1}->{forms}};
7 Einträge, 1 Seite |