Hi all, I need some assistance with the xml writer. I could possbly figure this out myself, but I have a deadline so no time to fiddle.
I am writing an xml file with perl as items get updated from the front end by users.
my query is that I have to write a xml query where it will use all the inputs given from a database, using foreach statement, we'll not go to the database so here is what I want to achieve.
I have a list of devices and ports, I need to create a button based on a filter, the filter would be something like this where node='node1' and port='port1'
the xml file gets populated based on filter names and filters can only exist once.
so here is an example of the script.
## I wrote this on here, so don't judge on errors, I just need an answer for the main question.
my $output = IO::File->new(">wheretowrite.xml");
my $writer = XML::Writer->new(OUTPUT => $output);
my @device_list = (
"node1 port1" ,
"node2 port2" ,
@get_data = split ( ' ' , $node );
$device_name = @get_data;
$port_name = @get_data;
$writer->startTag("filter", "name" => "all_events", "sql" => "(where
+ node ="$device_name and port=$port_name") or (where node="device_nam
+e and port=$port_name"), "label" => "just-testing", "view" => "Defaul
$writer->endTag( "filter" );
As you can see, I need to write the $device_name and $port_name in the single filter, the way it does currently do it (as above) it will do a foreach and try to write the filter xml each time, but as it can only exist once it will end up with a single filter with single device and port.
trying to put the foreach inbetween the middle of the xml writer statement, it will return an error.
the end result should end in (where node='node1" and port=port1) or (where node='node2" and port=port2)
so whether there are 100 nodes and ports or 1000's it must write in that sequence in a single filter.
i hope this made sense.