How to create a xml file using Perl Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to create a xml file using Perl Script
# 1  
Old 05-13-2010
How to create a xml file using Perl Script

Hi All,
I have some data which needs to be saved in the xml file format.Can you guys please let me know how to do this using perl script.

NOTE: the template of the xml file shall be depending on validation of the data done for some requirements. Basically to summarise, the fields in the xml file may differ depening on the data values.

Kindly let me know how to handle this in Perl Scirpt.


Thanks in Advance!!
Giri
# 2  
Old 05-13-2010
Please provide some sample data.
How does the input look like? How should the output look like?
# 3  
Old 05-13-2010
Hi,
the input and ouput file are as follows.
Input data file shall contan plan_name,service name,deal_name, bal_info_index,subscription_index.

Output Xml file:
Code:
<plan ondemand_billing="no">
<plan_name>DE_PR_Package__Basic+1Premium_Film__Monthly</plan_name>
<service_deal>
<service_name>/service/blue_movie</service_name>
<bal_info_index>0</bal_info_index>
<subscription_index>0</subscription_index>
</service_deal>
<service_deal>
<service_name>/service/ppv</service_name>
<deal_name>DE_PR_PPV</deal_name>
<bal_info_index>0</bal_info_index>
<subscription_index>0</subscription_index>
</service_deal>
<service_deal>
<service_name>/service/broadband</service_name>
<deal_name>DE_PR_Package__Basic+1Premium_Film__Monthly</deal_name>
<bal_info_index>0</bal_info_index>
<subscription_index>0</subscription_index>
</service_deal>
</plan>

Thanks,
Giri

Last edited by Scott; 05-13-2010 at 10:26 AM.. Reason: Code tags, please...
# 4  
Old 05-13-2010
use xmltwig.
it is fabulous.

XML, The Perl Way
# 5  
Old 05-13-2010
how about using xml simple with xmlout() ?
which one do you suggest ?
# 6  
Old 05-13-2010
well, I haven't used XML::Simple.

The work I've been doing lately involves all sorts of XML processing:
creating, parsing, editing, extracting data with Xpath queries.
XML::Twig does all these things with ease.
the xpath facility is absolutely brilliant.
Throw away your Saxon and Xquery and XSLT code.

I've been using it a lot in a production system on multiple platforms.
It is quality.
This User Gave Thanks to bigearsbilly For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to read a csv and create xml - Perl

I have a csv file like below. john,r2,testdomain1,john.r2@hex.com,DOMAINADMIN,testdomain1.dom maxwell,b2, testdomain1,maxwell.b2@hex.com,DOMAINADMIN,testdomain1.dom I would need the perl script to read the above csv and create an xml like below. <Users> ... (1 Reply)
Discussion started by: Tuxidow
1 Replies

2. Shell Programming and Scripting

UNIX/PERL script to convert XML file to pipe delimited format

Hello, I need to get few values from a XML file and output needs to be written in another file with pipe delimited format. The Header & Footer of the Pipe Delimited file will be constant. The below is my sample XML file. I need to pull the values in between the XML tags <Operator_info to... (15 Replies)
Discussion started by: karthi1305561
15 Replies

3. Shell Programming and Scripting

Splitting xml file into several xml files using perl

Hi Everyone, I'm new here and I was checking this old post: /shell-programming-and-scripting/180669-splitting-file-into-several-smaller-files-using-perl.html (cannot paste link because of lack of points) I need to do something like this but understand very little of perl. I also check... (4 Replies)
Discussion started by: mcosta
4 Replies

4. Shell Programming and Scripting

Get multiple values from an xml file using one of the following commands or together awk/perl/script

Hello, I have a requirement to extract the value from multiple xml node and print out the values to new file to compare. Would be done using either awk/perl or some unix script. For example sample input file: ..... ..... <factories xmi:type="resources.jdbc:DataSource"... (2 Replies)
Discussion started by: slbmind
2 Replies

5. Programming

help need in the perl script that create one xml file form multiple files.

Hi every one, Please excuse me if any grammatical mistakes is there. I have multiple xml files in one directory, I need to create multiple XML files into one XML file.example files like this</p> file1:bvr.xml ... (0 Replies)
Discussion started by: veerubiji
0 Replies

6. Programming

Extract xml data and create word document using perl.

Hi, I have large xml data file.I need to extract node and some tags in the node and after I need to create word document. my XMl data is look like as below -<student> <number>24</number> <education>bachelor</bachelor> <specialization>computers</specialization> ... (3 Replies)
Discussion started by: veerubiji
3 Replies

7. Programming

extract xml data and create word document using perl.

hi, i have large xml file which contains students information, i need to extract student number and some address tags and create a word document for the extracted data. my data looking llike this <student> <number>24</number> <education>bachelors</education> ... (1 Reply)
Discussion started by: veerubiji
1 Replies

8. Shell Programming and Scripting

Create an XML tree using perl

Hi, I am having an xml file which looks like this: <Nodes> <Node> <Nodename>Student</Nodename> <Filename>1.txt</filename> <Node> <Nodename>Dummy</Nodename> <Filename>22.txt</filename> </Node> </Node> </Nodes> The text files will have data like this: #1.txt... (8 Replies)
Discussion started by: vanitham
8 Replies

9. Shell Programming and Scripting

perl script to update a xml file

Hi experts, I have a set of xml files in folder which has the below field. <mm:sessionID>157.235.206.12900397BE4:A</mm:sessionID>, I need to update this field regularly with new session id, which I have it from a login file. Can anyone tell me how to add a new value in <mm:sessionID>... (3 Replies)
Discussion started by: amvarma77
3 Replies

10. Shell Programming and Scripting

Perl script to extract 'ID' From XML File

File1.xml <?xml version.........> - <abcd:abcd_list version="1" www.john_uncle's_server.com" xmlns: - <device id="100"> <firmware>12.4(3d)</firmware> <location id="500">Sitting Room</location> </device> - <device id="101"> <firmware>12.4(3d)</firmware> <location id="501">Class... (1 Reply)
Discussion started by: sureshcisco
1 Replies
Login or Register to Ask a Question