Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?xml version="1.0" encoding="windows-1250"?>
<base>
<table nom="pilote">
<champs intitule="numpilote" nom="john" prenom="jina">
</champs>
</table>
<table nom="vol">
<champs intitule="xx32" ville="paris">
</champs>
</table>
</base>
[code]
my perl script
[code]
#!/usr/bin/perl
use XML::Simple;
use Data::Dumper;
$xml = new XML::Simple() ;
$data = $xml->XMLin("./fili.xml",ForceArray => 1);
print Dumper($data);
[code]
#!/usr/bin/perl
use XML::Simple;
use Data::Dumper;
$xml = new XML::Simple([COLOR=blue]ForceArray => 1[/color]) ;
$data = $xml->XMLin("./fili.xml");
print Dumper($data);
$xml = new XML::Simple(ForceArray => 1) ;
$data = $xml->XMLin("./fili.xml");
$VAR1 = {
'table' => [
{
'nom' => 'pilote',
'champs' => {
'prenom' => 'jina',
'nom' => 'john',
'intitule' => 'numpilote'
}
},
{
'nom' => 'vol',
'champs' => {
'intitule' => 'xx32',
'ville' => 'paris'
}
}
]
};
$xml = new XML::Simple() ;
$data = $xml->XMLin("./fili.xml");
$VAR1 = {
'table' => [
{
'nom' => 'pilote',
'champs' => {
'prenom' => 'jina',
'nom' => 'john',
'intitule' => 'numpilote'
}
},
{
'nom' => 'vol',
'champs' => {
'intitule' => 'xx32',
'ville' => 'paris'
}
}
]
};
forcearray => 1 (in)
This option should be set to '1' to force nested elements to be represented as arrays even when there is only one. Eg, with forcearray enabled, this XML:
<opt>
<name>value</name>
</opt>
would parse to this:
{
'name' => [
'value'
]
}
instead of this (the default):
{
'name' => 'value'
}
$VAR1 = {
'name' => 'value'
};
As it says in the docs, ForceArray effects nested elements, it doesn't appear to have the same behaviour on attributes within the elements.perldoc XML::Simple said:ForceArray => 1 *# in - important*
This option should be set to '1' to force nested elements to be represented as arrays even when there is only one.
ForceArray => [ names ] # in - important
This alternative (and preferred) form of the 'ForceArray' option allows you to specify a list of element names which should always be forced into an array representation, rather than the 'all or nothing' approach above.
The problem isn't focalized on forcearray but if i can't use forcearray, i can't use the others options of the XML::Simple parckageIs there something I'm missing? Why do you need 'ForceArray'?