Questions tagged [xml-twig]

XML::Twig is a Perl module that provides easy and efficient processing of XML documents of all sizes.

In particular, it tries to avoid loading an entire XML document into memory at once so it can be used with huge files.

Resources

212 questions
8
votes
2 answers

"Out of memory" while parsing large (100 Mb) XML file using perl

I have an error "Out of memory" while parsing large (100 Mb) XML file use strict; use warnings; use XML::Twig; my $twig=XML::Twig->new(); my $data = XML::Twig->new ->parsefile("divisionhouserooms-v3.xml") ->simplify(…
gangabass
  • 10,607
  • 2
  • 23
  • 35
7
votes
1 answer

Purge XML Twig inside sub handler

I am parsing large XML files (60GB+) with XML::Twig and using it in a OO (Moose) script. I am using the twig_handlers option to parse elements as soon as they're read into memory. However, I'm not sure how I can deal with the Element and…
Bram Vanroy
  • 27,032
  • 24
  • 137
  • 239
7
votes
2 answers

XML::Twig and save order of attributes

I am editing some XML files using XML::Twig below are the code : my $twig = XML::Twig->new( pretty_print => 'indented', twig_handlers => { Vendor => sub { $_->set_att( 'ID' => $_->{'att'}->{'att1'} ); …
smith
  • 3,232
  • 26
  • 55
6
votes
1 answer

in XML:TWIG, how to stop parsing once find the interested element

I only want to parse an interested element of xml (e.g. see below: class element with name equals to math) and I want to stop once the first element hitting this condition is parsed. (since There is only one class whose name is math, it is…
user399517
  • 3,543
  • 2
  • 19
  • 15
6
votes
3 answers

Perl, XML::Twig, how to reading field with the same tag

I'm working on processing a XML file I receive from a partner. I do not have any influence on changing the makeup of this xml file. An extract of the XML is: VW-XJC9
6
votes
1 answer

How can I get content using XML::Twig?

My aim is that start_tag_handler (see below) get the apps/title content when it finds an apps/title tag (see sample XML below). And end_tag_handler gets the apps/logs content when it finds an apps/logs tag. But instead this code returns null and…
tknv
  • 562
  • 1
  • 6
  • 23
5
votes
2 answers

Clear content in xml brackets in all files in directory tree on Windows using Strawberry Perl and twig

I want to clear whole content that is placed inside of elements in XML files in a directory tree. I am using Strawberry Perl for windows 64 bit. For example this XML file:
Piodo
  • 616
  • 4
  • 20
5
votes
2 answers

How can I extract child values from XML with Perl's XML::Twig?

I am parsing the XML file and trying to access the values in XML file. #!/usr/bin/perl -w use strict; use XML::Twig; my $file = 'files/camelids.xml'; print "File :: $file\n"; my $twig = XML::Twig->new(); $twig->parsefile($file); # print "twig ::…
Praveen
  • 61
  • 1
  • 4
5
votes
3 answers

How can I pass arguments and return values with XML::Twig's handler?

my question is: how to pass some arguments to XML:Twig's handler, and how to return the result from the handler. Here is my code, which hardcoded: . How to implement this by using…
user389955
  • 9,605
  • 14
  • 56
  • 98
5
votes
2 answers

String corruption and nonprintable characters using XML::Twig in Win32 Perl

This is a really weird problem. It's taken me practically all day to whittle it down to a small executable script that demonstrates the problem fully. Problem Summary: I'm using XML::Twig to pull a data snippet from an XML file, then I'm sticking…
Kurt W. Leucht
  • 4,725
  • 8
  • 33
  • 45
5
votes
2 answers

How to change XML to use empty-element tags?

I am new to XML::Twig. How can I change all empty elements to use empty-element tags () instead of a start-tag and end-tag combo ()? Input: Maurice
user1811486
  • 1,294
  • 2
  • 10
  • 17
5
votes
5 answers

How can I speed up XML::Twig

I am using XML::Twig to parse through a very large XML document. I want to split it into chunks based on the tags. Right now I have: my $xml = XML::Twig->new(twig_handlers => { 'change' => \&parseChange,…
user1897691
  • 2,331
  • 3
  • 14
  • 12
4
votes
1 answer

Large xml file parsing failed using XML::TWIG

I am trying parse a large xml file (around 100,000 records) using XML::Twig but perl parsing fails with error: perl.exe - Application Error: The instruction at "0x28086920" referenced memory at "0x00000004". The memory could not be "written"... I…
user1019072
  • 299
  • 1
  • 7
  • 17
4
votes
1 answer

XML::Twig Comment

I have an XML document which I need to convert to another type of XML. Some of the information cannot be encoded in the XML I want to convert to, so I want to store the extra information as comments. However, I cannot figure out how to create a…
Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
4
votes
1 answer

Parsing a file handle with XML::Twig

I see in the XML::Twig documentation the functions parse($text) for parsing scalars contain xml text, and parsefile($fileName) for reading in and parsing xml files. I would like to parse an input stream (a file handle or maybe STDIN). Still wading…
Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
1
2 3
14 15