#!/usr/bin/perl use strict; use warnings; use XML::LibXML; my $item_list = shift; my $xml = << '__XML__'; <BulkUpdate> <UpdateSets> <UpdateSet> <type name="MyType" /> <where> <cond_prop attrName="ID" cond_operator="="/> </where> <update> <update_prop attrName="sh4_SAP_ID" attrValue="" /> </update> </UpdateSet> </UpdateSets> </BulkUpdate> __XML__ my $dom = 'XML::LibXML'->load_xml(string => $xml); my ($sets) = $dom->findnodes('/BulkUpdate/UpdateSets'); my ($update) = $sets->findnodes('UpdateSet'); open my $in, '<', $item_list or die $!; while (<$in>) { chomp; my $set; if ($. > 1) { $set = $update->cloneNode(1); $sets->appendChild($set); } else { ($set) = $dom->findnodes('/BulkUpdate/UpdateSets/UpdateSet[las +t()]'); } my ($cond_prop) = $set->findnodes('where/cond_prop'); $cond_prop->{attrValue} = $_; } print $dom;
In reply to Re: Create an XML file from input text file
by choroba
in thread Create an XML file from input text file
by szpt9m
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |