Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Confusion ,XML::SIMPLE with DATA:DUMPER

by monkey_boy (Priest)
on Nov 20, 2006 at 17:00 UTC ( #585087=note: print w/replies, xml ) Need Help??

in reply to Confusion ,XML::SIMPLE with DATA:DUMPER

A little snipet to get you going, you could easyly post-process the output if this:
use strict; use warnings; use XML::Twig; my $t = XML::Twig->new( twig_handlers => { 'PHONENO/ENTRY' => \&print_n_purge, 'REASON/ENTRY' => \&print_n_purge, } ); $t->parsefile($your_xml_file); sub print_n_purge { my( $t, $elt)= @_; print $elt->parent->name,":",$elt->text , "\n"; $t->purge; };

This is not a Signature...

Replies are listed 'Best First'.
Re^2: Confusion ,XML::SIMPLE with DATA:DUMPER
by ultibuzz (Monk) on Nov 20, 2006 at 20:04 UTC

    xml::twig sounds good, if vpn is working right i will test now some.
    i just came home from a 12 hour working day
    big thanks to joos and you for that hind with xml:twig

    UPDATEi have tryed this snipet and this is the output

    PHONENO:877465535 PHONENO:86719273704 PHONENO:8671881760 PHONENO:8671969876 not well-formed (invalid token) at line 17, column 14, byte 313 at C:/ +Perl/site/lib/XML/ line 187

    i added 'REASON/DATE_OCCURRED' => \&print_n_purge because i thought its related to that i don't take this element of REASON. but this didn't help

    UPDATE2 well now i don't understand this, i jsut copy the informations ina a file called test2.xml and start over and i got this

    PHONENO:867112593 PHONENO:86719273704 PHONENO:8671881760 PHONENO:8671969876 REASON:highspender limit exceeded no element found at line 52, column 16, byte 1252 at C:/Perl/site/lib/ +XML/ line 187

    as you can see now the Reason is ther still an error but the reason is printed

      Looks like your "XML" file isn't well-formed (note the line and column numbers in the error messages refer to the line and column in the XML file). In effect that means it's not valid XML and you should return it to whoever created it and let them figure out how to write well-formed XML first.

      update: it appears the problem is the ü character. Adding an xml prolog that indicates the correct encoding should fix it. Add something like this at the very beginning of the file:

      <?xml version="1.0" encoding="ISO-8859-1"?>

      Your encoding is probably iso-8859-1 (latin-1), CP1252 (latin windows encoding) or utf-8 (one of the unicode encodings)

        i forgot to xopy the firstline of the main file
        <?xml version="1.0" encoding="ISO-8859-1"?>
        is what is standing there
        with this in the testfile the error is gone

        this file is in kinda good shape, sometimes we get files i can't even say what is waht but we need to live with that ;/

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://585087]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2021-06-19 21:43 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (93 votes). Check out past polls.