473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Chunk by Chunk processing of XML

Need to process an XML Chunk by Chunk.....

I had an XML. It will consist of a number of similar type of tags and what I want to do is to process a certaing group of methods on each of these similar group of tags everytime.

I tried it out with XML::Twig. But not able to get it as I am new to Perl.

Can anybody help me out in this please.....

Eg:
<tsip:dataFeed=....>
<tsip><invention>.....</invention></tsip>
<tsip><invention>.....</invention></tsip>
<tsip><invention>.....</invention></tsip>
</tsip:dataFeed>

Now what I want to do is , to process each <tsip></tsip> element using some methods which are user-defined.
Mar 6 '07 #1
7 2216
KevinADC
4,059 Expert 2GB
Do you have this same question on another forum? Has it recieved any replies if you do?
Mar 6 '07 #2
@rellaboyina

Try something like this:

Expand|Select|Wrap|Line Numbers
  1. $tag = "tsip";
  2.  
  3. @lines = (
  4.   "<tsip:dataFeed=....>",
  5.   "<tsip><invention>.....</invention></tsip>",
  6.   "<tsip><invention>.....</invention></tsip>",
  7.   "<tsip><invention>.....</invention></tsip>",
  8.   "</tsip:dataFeed>",
  9. );
  10.  
  11. sub userDefinedMethod {
  12.   my($content) = @_;
  13.  
  14.   printf("$content\n");
  15. }
  16.  
  17. for $line ( @lines ) {
  18.   if ( $line =~ m(^<$tag>(.*)</$tag>$) ) {
  19.     userDefinedMethod($1);
  20.   }
  21. }
Greetz, Doc
Mar 7 '07 #3
Do you have this same question on another forum? Has it recieved any replies if you do?
Till now I haven't recieved any replies for this query. Can u help me out please?
Mar 12 '07 #4
KevinADC
4,059 Expert 2GB
did you read the suggestion posted by doc?
Mar 13 '07 #5
I have tried with what Mr.doc has suggested. But it will not fulfill my purpose.

For that what I was doing is, I have taken the module XML::Twig, and parsing the file using the xpaths of the required tags, attributes and the elements.

But to process each <tsip> what I was doing is that, creating a separate xml file for each tsip and parsing that which will ultimately result in the more memory consumption.

So I would like to know that whether there is any process of parsing the xml file without following the process which I did and taking the less memory.
Mar 15 '07 #6
KevinADC
4,059 Expert 2GB
I'm sure there is but it's something I have no practical experience with. There are a lot of XML modules, maybe one of the other ones will work for you:

XML::XPath or XML::LibXML
Mar 15 '07 #7
I have already tried with XML::XPath. But the module XML::Twig is giving the best performance when compared to XML::XPath. So can you please help me out in this?
Mar 23 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: K.Simon | last post by:
Hello, I'm converting books from Docbook to HTML-chunk. For my needs it is necessary to append the list of figures at the end instead the beginning of the book as it is default in docbook. After...
8
by: Darsant | last post by:
I'm currently reading 1-n number of binary files, each with 3 different arrays of floats containing about 10,000 values a piece for a total of about 30,000 values per file. I'm looking for a way...
3
by: Eric Anderson Vianet SAO | last post by:
hello all When i tried ´pg_dump -v -f dump.dmp dtbtransporte´ I got the error: pg_dump: restoring data for table tbdmovimento pg_dump: dumping out the contents of table tbdmovimento ...
1
by: John | last post by:
Hi First of all apologies for posting so much code but this is rather involved and I am totally stumped. Basically I have a main form (Staff Batch SMS/E-Mail) which calls a function (SendSMS) in...
9
by: zerro | last post by:
Hello, I try to understand heap overflows (under Linux), but can not understand one thing with freeing memory allocated with malloc(). Here it comes: I have a program called 1.c: main() {...
0
by: Ganapathy | last post by:
I have COM dll code written in VC 6.0. When i tried compiling this code in VC 7, The MIDL cmpiler gets called twice. i.e. it initially compiles fully & immediately a line - 64 bit processing'...
2
by: muslimak | last post by:
I have a perl script that throws an error "illegal division by zero" chunk 37. FYI, this script was the one that worked fine two days back. There is no change in the script. Can anyone tell...
3
by: rhicco75 | last post by:
Hi every one i am new with VB6.0 and i wanted to know if you know a site that will teach me on how to use the Get/Append Chunk... I need a step by step tutorial and also where can I find...
10
by: Bill Cunningham | last post by:
My compiler gives me a syntax error on line 13 and I don't see. Here's the code. #include <stdio.h> int chunk (char *n1, char *n2, int bs, int nb); main(){ int chunk (char *n1, char *n2,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.