D
David Staschover
Hi,
Can someone help me get this working?
Sample XML File test.xml:
<top1>
<field>
<value1>100</value1>
<value2>test value1</value2>
</field>
<field>
<value1>107</value1>
<value2>test value2</value2>
</field>
</top1>
This program gets and prints the values for value1 and value2 without a
problem:
#!/usr/bin/perl
use XML::Simple;
$simple = XML::Simple->new();
$struct = $simple->XMLin("test.xml", forcearray => 1, keeproot => 1);
for (@{$struct->{top1}->[0]->{field}})
{
print "
$_->{value1}->[0]
$_->{value2}->[0]
";
}
How can I get the same output using this XML file (I added <top>)?
<top>
<top1>
<field>
<value1>100</value1>
<value2>test value1</value2>
</field>
<field>
<value1>107</value1>
<value2>test value2</value2>
</field>
</top1>
<top>
Thanks in advanced!
David
Can someone help me get this working?
Sample XML File test.xml:
<top1>
<field>
<value1>100</value1>
<value2>test value1</value2>
</field>
<field>
<value1>107</value1>
<value2>test value2</value2>
</field>
</top1>
This program gets and prints the values for value1 and value2 without a
problem:
#!/usr/bin/perl
use XML::Simple;
$simple = XML::Simple->new();
$struct = $simple->XMLin("test.xml", forcearray => 1, keeproot => 1);
for (@{$struct->{top1}->[0]->{field}})
{
print "
$_->{value1}->[0]
$_->{value2}->[0]
";
}
How can I get the same output using this XML file (I added <top>)?
<top>
<top1>
<field>
<value1>100</value1>
<value2>test value1</value2>
</field>
<field>
<value1>107</value1>
<value2>test value2</value2>
</field>
</top1>
<top>
Thanks in advanced!
David