Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

text on multiple lines to XML using PERL

by cciiaandrei (Initiate)
on Feb 18, 2019 at 14:06 UTC ( #1230103=perlquestion: print w/replies, xml ) Need Help??
cciiaandrei has asked for the wisdom of the Perl Monks concerning the following question:

Hello. I want to create a PERL script to convert something like this into XML, with logical headers.

acc_BM: C:\work\workspace\ACC-8.6.0\TAM\plugins\BswM_TS_TxDxM1I14R0\sr +c\BswM.c, 31: warning: redundant redeclaration of 'Com_MainFunctionRx +' [-Wredundant-decls] (included from C:/work/workspace/ACG-8.6.0/TAM/ +plugins/Com_TS_TxDxM6I3R0/include/Com_Api_Static.h, line 1092) extern FUNC(void, COM_CODE) Com_MainFunctionRx ^~~~~~~~~~~~~~~~~~, TestSequences: SwInt_ +ConTest_TestInt_ATS_MODE_ECUM SwInt_ConTest_TestInt_ATS_MODE_RestartE +CUM acc_BC: C:\work\workspace\ACC-8.6.0\tests\Conformance\IN\SwInt_ConTest +_CS_Rte_SomeIpXf_Com_p0\output\generated\src\Com_Lcfg.c, 40: warning: + redundant redeclaration of 'Com_MainFunctionTx' [-Wredundant-decls] +(included from C:/work/workspace/ACG-8.6.0/TAM/plugins/Com_TS_TxDxM6I +3R0/include/Com_Api_Static.h, line 833) extern FUNC(void, COM_CODE) Com_MainFunctionTx ^~~~~~~~~~~~~~~~~~, TestSequences: SwInt_ +ConTest_CS_Rte_SomeIpXf_Com_p0

So the steps would be:

  1. To read all the .txt file(on all lines) that contains that data
  2. To create a blank abc.xml document
  3. To define the XML schema with tags like Module, Path, Warning, Test Sequence
  4. To populate with data the new created .xml file , so it should look like that:
<Warnings> <Module>acc_BM</Module> <Path>C:\work\workspace\ACC-8.6.0\TAM\plugins\BswM_TS_TxDxM1I14R0 +\src\BswM.c</Path> <warning>redundant redeclaration of 'Com_MainFunctionRx' [-Wredun +dant-decls] (included from C:/work/workspace/ACG- 8.6.0/TAM/plugins/Com_TS_TxDxM6I3R0/include/Com_Api_Static.h, li +ne 1092) extern FUNC(void, COM_CODE) Com_MainFunctionRx</warning> <TestSequence>SwInt_ConTest_TestInt_ATS_MODE_ECUM SwInt_ConTest_T +estInt_ATS_MODE_RestartECUM acc_BC: C:\work\workspace\ACC-8.6.0\tests\Conformance\IN\SwInt_C +onTest_CS_Rte_SomeIpXf_Com_p0\output\generated\src\Com_Lcfg.c</TestSe +quence> </Warnings>

It has to be smart, to be self adjust, because for example on test sequences, the names will vary, but will be like XXX.c

Replies are listed 'Best First'.
Re: text on multiple lines to XML using PERL
by Laurent_R (Canon) on Feb 18, 2019 at 14:34 UTC
    Please use markup to format your post: Markup in the Monastery

    Update: changed the link to the markup page, following Marto's comment below.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1230103]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2019-03-23 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How do you Carpe diem?





    Results (114 votes). Check out past polls.

    Notices?