Help required in Building an XML using SAX Parser in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help required in Building an XML using SAX Parser in perl
# 1  
Old 05-18-2011
Help required in Building an XML using SAX Parser in perl

I want to use sax parser for my application as i have 5 Lakhs of data.

I have the xml file like this
Code:
<Nodes>
	<Node>
	 <NodeName>Company</NodeName>
     <File>employee_details.csv</File>
     <data>employee_data.txt</data>
	 <Node>
	 <NodeName>dummy</NodeName>
     <File>employee_details1.csv</File>
     <data>employee_data1.txt</data>
	</Node>
	</Node>
</Nodes>
#Contents of employee_data.txt
Empname,Empcode,EmpSal:Currency,Empaddr
#Contents of employee_details.csv (like this huge data)
Alex,A001,1000:USD,Bangalore
Aparna,B001,1000:RUBEL,Bombay
#Contents of employee_data1.txt
phone,fax
#Contents of employee_details1.csv (like this huge data)
44568889,123345656
23232323,454545757

I have to process these and print it in the xml format. I want to use SAX Parser.

Output:
Code:
<Company>
<Empname>Alex</Empname>
<Empcode>A001</Empcode>
<EmpSal=USD>1000</EmpSal>
<Empaddr>Bangalore</Empaddr>
<phone>44568889</phone>
<fax>123345656</fax>
</Company>
<Company>
<Empname>Aparna</Empname>
<Empcode>B001</Empcode>
<EmpSal=RUBEL>1000</EmpSal>
<Empaddr>Bombay</Empaddr>
<phone>23232323</phone>
<fax>454545757</fax>
</Company>

I am very new to perl parser so finding it difficulty in building an xml tree.

Since there is huge amount of data parsing and putting the parsed content will be better using an Sax parser as read by posts.

How can i get the above output using an SAX parser?

Help is very much required.

Regards
Vanitham
# 2  
Old 05-19-2011
# 3  
Old 05-19-2011
Quote:
Originally Posted by fpmurphy
Hi,

Thanks for your mail. Will go through the tutorials and get back to u for further help.

Regards
Vanitha

---------- Post updated at 04:38 AM ---------- Previous update was at 02:29 AM ----------

Quote:
Originally Posted by fpmurphy
Hi,

I just went through the tutorials but i did not understand how to handle and write the events i.e how to get the main node and parse the file and create an xml tree as mentioned above mail.

Help is very much required?

Regards
Vnitha
# 4  
Old 05-19-2011
I was going to ask what a Lakh is, but I found it.

Does the original .xml file really have nested <Node>s?

Are there only four filenames that are replicated for every employee? Or are these just examples?
# 5  
Old 05-20-2011
Quote:
Originally Posted by KenJackson
I was going to ask what a Lakh is, but I found it.

Does the original .xml file really have nested <Node>s?

Are there only four filenames that are replicated for every employee? Or are these just examples?
Hi,

It is <Nodes> not <Node>s.

These are just example u can say a sample file more records are there.

Regards
Vanitha
# 6  
Old 05-20-2011
Quote:
Originally Posted by vanitham
It is <Nodes> not <Node>s.
The example has
<Node>
...
<Node>
...
</Node>
</Node>

I call that "nested <Node>s".
It seems odd and surprising, so I'm just asking if it's real or a typo.
# 7  
Old 05-20-2011
Quote:
Originally Posted by KenJackson
The example has
<Node>
...
<Node>
...
</Node>
</Node>

I call that "nested <Node>s".
It seems odd and surprising, so I'm just asking if it's real or a typo.
Hi,

The main nodes is Employee and others are under that node.

Is there any possibility of building an xml tree using an sax parser?

Regards
Vanitha
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HTML to XML parser

Hello forum, I am having problems to write a bash script. I am trying to get some information from a web page, I want to format it to XMLTV. This is web page: Programación de las cadenas etb1, etb2, etb3, canal vasco y etb sat | EITB Televisión I want to get something like this: <programme... (1 Reply)
Discussion started by: jlazkano
1 Replies

2. Shell Programming and Scripting

Help required converting XSD to XML file in PERL

Hi, Please find below the xsd. <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="fruitorder"> <xs:complexType> <xs:sequence> <xs:element name="orderperson"... (2 Replies)
Discussion started by: vanitham
2 Replies

3. Shell Programming and Scripting

Where to find 64-bit based perl module like XML::Parser::Expat?

Q: Where to get a 64 bit Expat.so? I run a perl script and got this error: Can't load '/usr/perl5/vendor_perl/5.8.4/i86pc-solaris-64int/auto/XML/Parser/Expat/Expat.so' for module XML:parser::Expat: ld.so.1:myPerl: fatal:... (0 Replies)
Discussion started by: lilili07
0 Replies

4. Shell Programming and Scripting

Facing problem in XML::parser module in PERL

HI, I have XML file which is having values as Spanish character (UTF-8 encoding). I am using XML::parser module but my code is not able to read those characters. I did goggling but not able to find suitable solution. Anybody please help me out. XML file having characters like: ñ I am... (1 Reply)
Discussion started by: jatanig
1 Replies

5. UNIX for Advanced & Expert Users

XML parser to generate Tuxedo UD files

Hi, My requirement is like this. I have an XML file which needs to be converted to Tuxedo UD files(param name and param value). Does anybody have a sample perl xml parser script for this? (0 Replies)
Discussion started by: guruprasadpr
0 Replies

6. Shell Programming and Scripting

xml-parser with perl

Hello I want to write an xml- parser with perl an i use the libary XML::LibXML. I have a problem with the command getElementsByTagName. If there is an empty tag, the getElementsByTagName method returns a NodeList of length zero. how can i check if this is a nodelist of lenght zero?? i... (1 Reply)
Discussion started by: trek
1 Replies

7. Shell Programming and Scripting

Perl XML:Parser help

I am very new to XML. Really I have an excel file that I am trying to read w/ Perl on a Linux machine. I don't have a mod for reading excel files so I have to convert the excel file to xml to be able to read it. I can read the file and everything is ok except...the Number style is being dropped... (0 Replies)
Discussion started by: vincaStar
0 Replies

8. Shell Programming and Scripting

xml parser in perl

hi all i want to read xml file in perl i am using XML::Simple for this. i am not getting how to read following file removing xml file due to some reason (1 Reply)
Discussion started by: zedex
1 Replies

9. Shell Programming and Scripting

Help required on building the logic

Hi, Can anyone please help me on building the logic for writing a shell script which can delete blank lines from a file and count the number of duplicate lines in a file. Thanks, Indra (2 Replies)
Discussion started by: igandu
2 Replies

10. HP-UX

XML parsing performace comparison with windows using sax

sorry wrong forum..i dont know how to delete this or how to move it to HP UX section... I tested SAX XML parsing using xerces(http://xerces.apache.org/xerces-j/). I tested on Windows XP and HP-UX . I found that parsing time on HP is 5 times that on Windows. My server startup reads a lot of XML... (1 Reply)
Discussion started by: saurabh.sid
1 Replies
Login or Register to Ask a Question