I wrote a script but its not capable of printing common xml tags in the output file.
Code:
use strict;
# Open the ch2_xml_users.csv file for input
open(CSV_FILE, "ch2_xmlusers.csv") ||
die "Can't open file: $!";
# Open the ch2_xmlusers.xml file for output
open(XML_FILE, ">ch2_xmlusers.xml") ||
die "Can't open file: $!";
# Print the initial XML header and the root element
print XML_FILE "<ZantazAccountManagement xmlns\=\"http\:\/\/www\.zantaz\.com\/\" xmlns\:xsi\=\"http\:\/\/www\.w3\.org\/2001\/XMLSchema\-instance\" xmlns\:ns1\=\"http\:\/\/www\.zantaz\.com\/\" xsi\:schemaLocation\=\"http\:\/\/www\.zantaz\.com\/ schema\.xsd\" ns1\:action\=\"UPDATE\">
";
print XML_FILE " <BillingGroups>
<BillingGroup>
<Name>testdomain1</Name>
<Type>-</Type>
<CustomerName>testdomain1</CustomerName>
</BillingGroup>
</BillingGroups>";
# The while loop to traverse through each line in users.csv
while(<CSV_FILE>) {
chomp; # Delete the new line char for each line
# Split each field, on the comma delimiter, into an array
my @fields = split(/,/, $_);
print XML_FILE<<"EOF";
<DomainName>testdomain1</DomainName>
<User>
<UserName>$fields[0].$fields[1].$fields[3].$fields[4]</UserName>
<Password>
<Value>Skyline\@123</Value>
</Password>
<BillingGroupName>$fields[4]</BillingGroupName>
<DataSource>sa</DataSource>
<UserProfile>
<LastName>$fields[1]</LastName>
<FirstName>$fields[0]</FirstName>
<ContactEmail>$fields[2]</ContactEmail>
<SendItToMe>nobody\@zantaz.com</SendItToMe>
</UserProfile>
</User>
<UserRoleAssignment>
<UserName>$fields[0].$fields[1].$fields[3].$fields[4]</UserName>
<RoleName>DomainAdmin</RoleName>
<Entities>
<Entity ns1:type="Applications">
<EntityName>adm</EntityName>
</Entity>
</Entities>
</UserRoleAssignment>
<UserRoleAssignment>
<UserName>$fields[0].$fields[1].$fields[3].$fields[4]</UserName>
<RoleName>Researcher</RoleName>
<Entities>
<Entity ns1:type="Applications">
<EntityName>ds</EntityName>
</Entity>
</Entities>
</UserRoleAssignment>
EOF
}
# Close the root element
print XML_FILE "</ZantazAccountManagement>";
# Close all open files
close CSV_FILE;
close XML_FILE;
items marked in red are common tags in this xml. I am not sure how I can print them while working on while loop. Can any one help me with this please?
Hi:
I have a collection of mp3s and I need to create 1 xml file per mp3.
I have:
recording1.mp3
recording2.mp3
etc
and I want to generate this kind of files.
recording1.xml
recording2.xml
and inside each xml file I need to add a url prefix and then the filename at the end.
... (4 Replies)
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... (5 Replies)
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)
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)
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)
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)
hi, someone to know how can i read a specific column of csv file and search the value in other csv columns if exist the value in the second csv copy entire row with all field in a new csv file. i suppose that its possible using awk but i m not expertise thanks in advance (8 Replies)
Hello everybody,
I have a double mission with some XML files, which is pretty challenging for my actual beginner UNIX knowledge. I need to extract some strings from multiple XML files and create a new XML file with the searched strings..
The original XML files contain the source code for... (12 Replies)
we have a CSV which i need to convert to XML using Perl or Unix shell scripting.
I was able to build this XML in oracle database. However, SQL/XML query is running for long time. Hence, I'm considering to write a Perl or shell script to generate this XML file. Basically need to build this XML... (3 Replies)
I have a CSV file that looks like this:
File,Name,birthdate,Amount
File1.xml,Name1,01.02.19,1000
File2.xml,Name2 01.02.20,1000
File3.xml,Name3,01.02.21,1000
I need it to turn it into an XML file for each row, My ultimate goal is for the File1.xml look like this:
<?xml version="1.0"... (5 Replies)