Hi,
I'm mainly used to work with XML::Simple, so my XML parsing skills are what you can call "novice" ;-)
However, now I have problems since I need to process a quite large file (12.2 mb) , and XML::Simple croaked with a "killed" message. I've also tried XML::Bare, worked great on my local computer, but on the server it also croaked with "Segmentation fault".
I suspect that the file is too large for these modules to process.
So, here are my questions:
1. Do you know how I can "tweak" the modules above to optimize the performance?
2. If not, what other module can do the job? I tried XML::Parser, but frankly I didn't find a good method browse the data - I simply didn't "get" how to use it in a good way:) (I'm used to access the data in the way that XML::Simple/XML::Bare serves it)
Example data below. I want to browse each -product- to fetch -product_id- and loop over -attributes- to get the values of each -attribute- tag.
<?xml version="1.0" encoding="ISO-8859-1"?>
<feed>
<timestamp>Thu, 11 Sep 2014 08:58:59 +0200</timestamp>
<language_product_id>sv</language_product_id>
<products>
<product>
<product_id>ABC123</product_id>
<name>My product</name>
<attributes>
<attribute>
<group>
<id>1507</id>
<name>Engines</name>
</group>
<value>
<id>301</id>
<value>Generator</value>
</value>
</attribute>
<attribute>
<group>
<id>1561</id>
<name>Längd (i mm)</name>
</group>
<value>
<id></id>
<value>2625</value>
</value>
</attribute>
<attribute>
<group>
<id>1498</id>
<name>Year model</name>
</group>
<value>
<id></id>
<value>01.1994</value>
</value>
</attribute>
<attribute>
<group>
<id>1518</id>
<name>Year model (to)</name>
</group>
<value>
<id></id>
<value>12.1998</value>
</value>
</attribute>
<attribute>
<group>
<id>12033</id>
<name>Vehicle equipment</name>
</group>
<value>
<id>12019</id>
<value>Maybe</value>
</value>
</attribute>
</attributes>
<references />
</product>
<product>
<product_id>XYZ789</product_id>
<name>My product</name>
<attributes>
<attribute>
<group>
<id>1507</id>
<name>Engines</name>
</group>
<value>
<id>301</id>
<value>Generator</value>
</value>
</attribute>
<attribute>
<group>
<id>1498</id>
<name>Year model</name>
</group>
<value>
<id></id>
<value>01.1985</value>
</value>
</attribute>
<attribute>
<group>
<id>1518</id>
<name>Year model (to)</name>
</group>
<value>
<id></id>
<value>12.1992</value>
</value>
</attribute>
</attributes>
<references />
</product>
</products>
</feed>
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.