Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
more useful options
 
PerlMonks  

How do you parse XML?

by Discipulus (Deacon)
on Dec 01, 2013 at 23:18 UTC ( #1065191=poll: print w/ replies, xml ) Need Help??

vote on How do you parse XML?

regular expressions
[bar] 70/13%
shiny regexes and rules offered by Perl 6
[bar] 3/1%
XML::Simple
[bar] 186/34%
other CPAN module
[bar] 96/18%
by looking at it on my monitor
[bar] 38/7%
I print it and I read it in spare time
[bar] 9/2%
first I convert it into $FORMAT, then I parse it
[bar] 7/1%
I hire someone to do it
[bar] 10/2%
using my custom module
[bar] 11/2%
I write a brand new language to do the task
[bar] 7/1%
on the server where I play as human, XML is forbidden
[bar] 22/4%
what is XML?
[bar] 37/7%
I speak XML natively
[bar] 19/3%
I write a new grammar for Perl 6
[bar] 7/1%
some other way
[bar] 24/4%
546 total votes
Comment on How do you parse XML?
Re: How do you parse XML?
by toolic (Chancellor) on Dec 01, 2013 at 23:35 UTC

    First letter: X

    Middle letter: M

    Last letter: L

    There. Your 3 letter string has been parsed.

    Or, using Perl:

    my @tokens = 'XML' =~ /(.)/g;
Re: How do you parse XML?
by lidden (Deacon) on Dec 02, 2013 at 02:34 UTC
    Some other way -> Not at all.

    I guess i could have gone with "what is XML" but I know what it is I just have no reason to deal with it.

Re: How do you parse XML?
by Discipulus (Deacon) on Dec 02, 2013 at 08:50 UTC
    i tried many in the last month and as suggested by a wise monks here, finally i tried XML::Twig and now i'm like a bird in twig with it. Maybe the docs can be upgraded because there are a lot of methods and some implicit ideas need to be explicitaded

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
        i think i recognize this luagh... ;=)

        L*

        There are no rules, there are no thumbs..
        Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: How do you parse XML?
by agentorange (Sexton) on Dec 02, 2013 at 10:27 UTC
    XML::Compile

    A very well thought out and constructed module.

Re: How do you parse XML?
by DrHyde (Prior) on Dec 02, 2013 at 10:49 UTC
Re: How do you parse XML?
by KevinZwack (Chaplain) on Dec 03, 2013 at 16:43 UTC
    XML::LibXML
      +1
      +1 -- because the existing use of XML::Simple was failing to catch invalid files and it was slower
Re: How do you parse XML?
by jesuashok (Curate) on Dec 04, 2013 at 03:25 UTC
    regular expressions
Re: How do you parse XML?
by smls (Pilgrim) on Dec 04, 2013 at 12:10 UTC
Re: How do you parse XML?
by blue_cowdawg (Prior) on Dec 04, 2013 at 14:16 UTC

    How do I parse XML? Not at all, I write a Perl script to do that. :-)


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: How do you parse XML?
by vitoco (Pilgrim) on Dec 04, 2013 at 15:33 UTC

    I never parse the XML as a whole... I usually search for some data between some tags in a given context using regular expression over a slurped string.

Re: How do you parse XML?
by Grimy (Monk) on Dec 06, 2013 at 08:31 UTC
    I don't parse XML. I let Chromium do the parsing, then fiddle with the resulting tree using JS/jQuery (yes, this works for arbitrary XML, not just XHTML).
Re: How do you parse XML?
by Ralesk (Pilgrim) on Dec 06, 2013 at 12:57 UTC

    I went with the ‘forbidden’ vote.

    XML is a horrible mess and we don’t use (parse, generate) it unless it’s absolutely required (by… uh… Java people for example, who seem to be obsessed with this overcomplicated and ambiguous, yet still particularly limited, format for data exchange).

Re: How do you parse XML?
by Anonymous Monk on Dec 10, 2013 at 01:24 UTC
    Depends on the XML file to parse, would used XML::Simple or XML::Twig.
Re: How do you parse XML?
by cavac (Chaplain) on Dec 18, 2013 at 13:29 UTC
    Technically, most of the time i use Maplat::Helpers::ConfigLoader, which in turn uses XML::Simple. But reading/parsing (most) XML files by looking at the screen works just as well.

    For complicated cases cat|grep|less and/or vim are also good options to quickly find the one relevant option in huge directories full of XML stuff :-)
    "I know what i'm doing! Look, what could possibly go wrong? All i have to pull this lever like so, and then press this button here like ArghhhhhaaAaAAAaaagraaaAAaa!!!"
Re: How do you parse XML?
by jellisii2 (Pilgrim) on Dec 26, 2013 at 15:22 UTC

    No mention of XML::Twig?! Let me rectify this right now: Of all the options I played with when I first had to start parsing XML, XML::Twig was the easiest for me to understand and get up to speed with. I've not found any case where it couldn't do the job I needed when dealing with XML. May $DEITY bless mirod.

    --edit: clarity. Need more coffee.

      ++ to XML::Twig; I was also surprised to find XML::Simple as the only Perl module listed in the poll. I've been using XML::Twig ever since some more experienced monks (Your Mother, toolic) guided me in this area, and it's not let me down. It also comes with the very handy xml_grep and xml_pp (pretty-printer), which find frequent use at work.

      I'm one of those "Java people" and I regularly deal with XML. I don't understand all the hate for it; after all, the very content you're reading right now was delivered to your computer using a form of XML. Right tool in the right place and all that.

        The list of options presented turned the poll into a silly joke.

        HTML is not a form of XML! It's similar, but one ain't a form of the other.

        I think most of the hate comes from the tendency of a lot of (especially) companies, that go absolutely bollocks when designing their XML formats producing thus insane, overcomplicated, hard to use messes. An from some people's insistence on using XML everywhere for everything. SOAP or HR-XML can turn anyone to a XML-hater.

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.

View List Of Past Polls


Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-04-18 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (466 votes), past polls