Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^5: Parsing xml using libXML

by Anonymous Monk
on Jul 18, 2013 at 13:58 UTC ( #1045104=note: print w/replies, xml ) Need Help??

in reply to Re^4: Parsing xml using libXML
in thread Parsing xml using libXML

well Its in my code

Well, it isn't. Your code builds no data structures, it just print stuff. So which is it, data structures, or print stuff, or what?

You say it doesn't print it all, so what would it print, how would the missing look?

Nevermind ,

#!/usr/bin/perl -- use strict; use warnings; use XML::LibXML 1.70; ## for load_html/load_xml/location use Data::Dump qw/ dd pp /; Main( @ARGV ); exit( 0 ); sub Main { my $loc = shift or die " Usage: $0 ko00010.xml $0\n\n"; my $dom = XML::LibXML->new( qw/ recover 2 / )->load_xml( location => $loc, ); orWhat( $dom -> documentElement ); } sub orWhat { my( $parent, $depth ) = @_; $depth ||= 0; my $dent = ' ' . ' ' x $depth; for my $child ( $parent->getAttributes ){ printf "%s%s[%s]\n", $dent, $child ->getName, $child->getValue +; } for my $kid ( $parent->nonBlankChildNodes ){ printf "%s%s[%s]\n", $dent, $kid->getName, pp( $kid->getValue +); orWhat( $kid, $depth + 1 ); ## recurse } return; } __END__ name[path:ko00010] org[ko] number[00010] title[Glycolysis / Gluconeogenesis] image[http...] link[http...] entry[undef] id[13] name[ko:K01623 ko:K01624 ko:K01622 ko:K16306] link[http...] graphics[undef] name[K01623...] fgcolor[#000000] bgcolor[#BFBFFF] type[rectangle] x[483] y[404] width[46] height[17]

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045104]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2017-07-24 00:03 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (347 votes). Check out past polls.