Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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]
NodeReaper preheats the oven before tossing in a TV dinner

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2017-11-18 09:17 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (277 votes). Check out past polls.