Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Parse multiple xml tags with different names to an array

by Anonymous Monk
on Sep 23, 2013 at 09:44 UTC ( #1055255=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Parse multiple xml tags with different names to an array
in thread Parse multiple xml tags with different names to an array

Hi, Thank you, but I am unable to figure out my exact requirement from a huge pool of info there in "state of web spidering in perl". Can you specify exactly which matches my req ? Thanks, Bala.

Well, I only link examples in one post, so that one :) and they all match your spec, they're all about extracting "tags" from xml ...

As Corion says, LibXML is one of the best choices available, use xpather.pl on your xml file to get a list of xpaths you can use to extract data you want (or url, but its better to download url to file for testing/development/until you figure stuff out )

examples of extracting "tags" are at Re: Stepping up from XML::Simple to XML::LibXML, Re^5: Parsing xml using libXML, Re: Nested XML Question,

Re^2: How to make use of dynamic namespace registration to replace the values of elements and attributes using XML::LibXML::XPathContext xml module

Re: Perl XML Search, Re: Filter for XML elements, Re: hi i want to retrieve the element and values from xml document, Re: XML::Simple XML / XMLin / XMLout? or something else?, Re: Struggling with XML, Re: XML Parsing, Re^6: Is there any XML reader like this? (XML::Simple beats LibXML hands down in the speed stakes!), Re^5: XML::LibXML problem,

https://metacpan.org/module/XML::LibXML::Node, https://metacpan.org/module/XML::LibXML::Element, https://metacpan.org/module/XML::LibXML


Comment on Re^3: Parse multiple xml tags with different names to an array
Re^4: Parse multiple xml tags with different names to an array
by rbala (Acolyte) on Sep 23, 2013 at 11:27 UTC
    Thanks for ur comments :)
Re^4: Parse multiple xml tags with different names to an array
by rbala (Acolyte) on Sep 25, 2013 at 08:40 UTC
    Hi ,

    With all your help , I am able to get the child nodes as an array using the code below :

    my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($string); my @nodes = $doc->findnodes("//ROOT_TAG/*"); Is there any possible ways to do this ?

    The resultant array elements of @nodes are all XML::LibXML::Elements object. I need this to be hash for my processing. Is there any way to do this ?

    Thanks,

    Bala.

      Yeah, make it into a hash, use XML::LibXML::Element methods, I linked the docs above
        Hi , I just tried with these methods , but could not figure out the exact method for getting hash. Can you please advise ? Thanks, Bala.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (16)
As of 2014-08-01 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (36 votes), past polls