I have a nested XML tags and need to append PF for ExternalId in Product XML
Input XML:
<Products>
<Product>
<ExternalId>317851</ExternalId>
</Product>
<Product>
<ExternalId>316232</ExternalId>
</Product>
<Product>
<ExternalId>13472</ExternalId>
</Product>
</Products>
Desired output result:
<Products>
<Product>
<ExternalId>PF317851</ExternalId>
</Product>
<Product>
<ExternalId>PF316232</ExternalId>
</Product>
<Product>
<ExternalId>PF13472</ExternalId>
</Product>
</Products>
I have tried using XML Simple.
One way using the module
XML::Twig.Content of
script.pl:Run it like:
That yields:
UPDATE: To print to a file I’ve added two modifications, one line to open the output file, and the
printmethod with the filehandle of the output file to print as argumentIt results in:
And it is invoked like: