CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
txt/XMl (two input files) to XML



Aug 24, 2016, 1:08 AM

Post #1 of 3 (2062 views)
txt/XMl (two input files) to XML Can't Post

I am new to perl programming language. I try to convert xml/txt to xml conversion.
I have two input file for conversion.

1) Txt file
2) deatil.xml

I need to merge the both details in single XML file. I have attached my code and also expected output. Please add code in my “” how to get the input from details.xml file. If anyone help me, I will move my next level of perl.
Attachments: (1.99 KB)

Veteran / Moderator

Aug 24, 2016, 6:19 AM

Post #2 of 3 (2045 views)
Re: [Jesjoshan] txt/XMl (two input files) to XML [In reply to] Can't Post

Please do not post your question in multiple areas. I've deleted you duplicate post.

We are not a free code writing service, so we're not going to do your homework assignment for you.

We will help you troubleshoot your code, but you need to explain how your code fails to do what you want.

You should not be using regex's to parse xml. Instead you should be using one of the XML parsers on CPAN.

You should not be using prototypes in your subs.

You should be using lexical vars for the filehandles and the 3 arg form of open.

(This post was edited by FishMonger on Aug 24, 2016, 6:20 AM)


Aug 28, 2016, 10:59 PM

Post #3 of 3 (2025 views)
Re: [FishMonger] txt/XMl (two input files) to XML [In reply to] Can't Post

If I call the another xml file in my perl. It’s print only “Content based on Cats”. But I need both my xml output + “Content based on Cats”.

My coding:

$catfile =$Fileloc . '\cats.xml';

open(TMPCAT,"$catfile") || die "cant open cats file";
$fulltext_CAT = do{local $/;<TMPCAT>};
close TMPCAT;
print "$fulltext_CAT\n";

if ($fulltext_CAT =~m#<earlyxmlFile includeEarlyPdf="false">#)

$xmltext = "Content based on Cats"

$outfile = $filename;
$outfile =~ s/\_O/\_J/ig;
print TTM $xmltext;
close TTM;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives